[Revised] Analysis code for

Exploring new technologies for future generations:

Exploration-exploitation trade-off in an intergenerational framework


We revised the analysis code after receiving peer-review comments. A series of Binomial regression analyses were added. Analyses for the second generation were added. The visualization codes were slightly revised.

Table of Contents

  • 1  Preparation
    • 1.1  Loading packages
    • 1.2  Execution environment
    • 1.3  Reading data
      • 1.3.1  Set Numerical ID for each participants (from 1 to 100)
    • 1.4  Color coordination
    • 1.5  Making Summary Efficiency
  • 2  Exploration
    • 2.1  Making Summary Data
    • 2.2  Visualizing exploration and exploration for each participant
    • 2.3  Making Summary Dataset
    • 2.4  Visualizing Summary
      • 2.4.1  Bar graphs + Cloud Plots
      • 2.4.2  Bar Graph
    • 2.5  t-tests
      • 2.5.1  Preparation
      • 2.5.2  Nonrepaid(OBL) vs. Asocial(IND)
      • 2.5.3  Repaid(VER) vs. Asocial(IND)
    • 2.6  Second Generation: OBL(unrepaid) vs. VER(repaid)
  • 3  Parameter Shifts
    • 3.1  Counting Over Exploration
    • 3.2  Length
    • 3.3  Width
    • 3.4  Thickness
  • 4  Efficiency
    • 4.1  Visualization in whole trials
    • 4.2  Mean Efficiency (pointless graph)
      • 4.2.1  (Visualization)
    • 4.3  FInal trial comparison
      • 4.3.1  Repaid vs. Asocial
      • 4.3.2  Nonrepaid vs. Asocial
      • 4.3.3  Second Generation
      • 4.3.4  (Cumulative Cultural Evolution)
  • 5  Questionnaire
    • 5.1  Strategy Proportion
    • 5.2  (Other scales)
    • 5.3  SVO
      • 5.3.1  Coding SVO
      • 5.3.2  SVO Categorization
      • 5.3.3  SVO summary
        • 5.3.3.1  By Three Category C:Prosocial, D: Defector (Proself+Competitor), N:non-classified
        • 5.3.3.2  Whether prosicial (1) or not (0)
    • 5.4  SVO + LM/GLM
      • 5.4.1  Data Merge
      • 5.4.2  Gaussian
        • 5.4.2.1  SVO as categorical
        • 5.4.2.2  SVO as contnious
      • 5.4.3  (Poisson)
      • 5.4.4  Binomial
        • 5.4.4.1  SVO as categorical
        • 5.4.4.2  SVO as continuous

$Note.$ The section titles with parenthesis "()" are additional analyses which were not reported in the manuscript.



Preparation¶

Loading packages¶

In [1]:
library(stringr)
library(dplyr)
library(reshape)
library(ggplot2)
library(psych)

library(viridis)
library(scales)
library(rcartocolor)
library(effsize)
library(extrafont)

library(tidyverse)
library(magrittr)

library(apaTables)
library(MBESS)
library(xtable)
library(Hmisc)
library(modelsummary)
options(warn = -1)
Attaching package: ‘dplyr’


The following objects are masked from ‘package:stats’:

    filter, lag


The following objects are masked from ‘package:base’:

    intersect, setdiff, setequal, union



Attaching package: ‘reshape’


The following object is masked from ‘package:dplyr’:

    rename



Attaching package: ‘psych’


The following objects are masked from ‘package:ggplot2’:

    %+%, alpha


Loading required package: viridisLite


Attaching package: ‘viridis’


The following object is masked from ‘package:viridisLite’:

    viridis.map



Attaching package: ‘scales’


The following object is masked from ‘package:viridis’:

    viridis_pal


The following objects are masked from ‘package:psych’:

    alpha, rescale



Attaching package: ‘effsize’


The following object is masked from ‘package:psych’:

    cohen.d


Registering fonts with R

── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──

✔ tibble  3.1.6     ✔ purrr   0.3.4
✔ tidyr   1.1.3     ✔ forcats 0.5.1
✔ readr   1.4.0     

── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ psych::%+%()        masks ggplot2::%+%()
✖ scales::alpha()     masks psych::alpha(), ggplot2::alpha()
✖ readr::col_factor() masks scales::col_factor()
✖ purrr::discard()    masks scales::discard()
✖ tidyr::expand()     masks reshape::expand()
✖ dplyr::filter()     masks stats::filter()
✖ dplyr::lag()        masks stats::lag()
✖ reshape::rename()   masks dplyr::rename()

Warning message:
“package ‘magrittr’ was built under R version 4.0.5”

Attaching package: ‘magrittr’


The following object is masked from ‘package:purrr’:

    set_names


The following object is masked from ‘package:tidyr’:

    extract



Attaching package: ‘MBESS’


The following object is masked from ‘package:psych’:

    cor2cov


Loading required package: lattice

Loading required package: survival

Loading required package: Formula


Attaching package: ‘Hmisc’


The following objects are masked from ‘package:xtable’:

    label, label<-


The following object is masked from ‘package:psych’:

    describe


The following objects are masked from ‘package:dplyr’:

    src, summarize


The following objects are masked from ‘package:base’:

    format.pval, units



Attaching package: ‘modelsummary’


The following object is masked from ‘package:Hmisc’:

    Mean


The following object is masked from ‘package:psych’:

    SD


Execution environment¶

In [2]:
sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 10.16

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] ja_JP.UTF-8/ja_JP.UTF-8/ja_JP.UTF-8/C/ja_JP.UTF-8/ja_JP.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] modelsummary_1.4.3 Hmisc_4.6-0        Formula_1.2-4      survival_3.2-7    
 [5] lattice_0.20-41    xtable_1.8-4       MBESS_4.9.2        apaTables_2.0.8   
 [9] magrittr_2.0.3     forcats_0.5.1      purrr_0.3.4        readr_1.4.0       
[13] tidyr_1.1.3        tibble_3.1.6       tidyverse_1.3.1    extrafont_0.19    
[17] effsize_0.8.1      rcartocolor_2.0.0  scales_1.1.1       viridis_0.5.1     
[21] viridisLite_0.4.0  psych_2.0.12       ggplot2_3.3.5      reshape_0.8.8     
[25] dplyr_1.0.7        stringr_1.4.0     

loaded via a namespace (and not attached):
 [1] nlme_3.1-149        fs_1.5.0            lubridate_1.7.10   
 [4] insight_0.19.7      RColorBrewer_1.1-2  httr_1.4.7         
 [7] repr_1.1.0          tools_4.0.3         backports_1.2.1    
[10] DT_0.17             utf8_1.2.2          R6_2.5.1           
[13] rpart_4.1-15        DBI_1.2.2           colorspace_2.0-2   
[16] nnet_7.3-14         withr_3.0.0         tidyselect_1.1.1   
[19] gridExtra_2.3       mnormt_2.0.2        compiler_4.0.3     
[22] extrafontdb_1.0     cli_3.1.1           rvest_1.0.0        
[25] htmlTable_2.4.1     xml2_1.3.2          checkmate_2.1.0    
[28] tables_0.9.17       pbdZMQ_0.3-4        digest_0.6.29      
[31] foreign_0.8-80      rmarkdown_2.9       base64enc_0.1-3    
[34] jpeg_0.1-9          pkgconfig_2.0.3     htmltools_0.5.7    
[37] dbplyr_2.1.1        fastmap_1.1.1       htmlwidgets_1.5.3  
[40] rlang_1.1.3         readxl_1.3.1        rstudioapi_0.15.0  
[43] generics_0.1.2      jsonlite_1.7.2      interp_1.0-33      
[46] Matrix_1.2-18       Rcpp_1.0.9          IRkernel_1.1.1.9000
[49] munsell_0.5.0       fansi_1.0.2         lifecycle_1.0.1    
[52] stringi_1.5.3       plyr_1.8.6          grid_4.0.3         
[55] parallel_4.0.3      crayon_1.4.2        deldir_1.0-6       
[58] IRdisplay_0.7.0     haven_2.3.1         splines_4.0.3      
[61] hms_1.1.0           tmvnsim_1.0-2       knitr_1.30         
[64] pillar_1.7.0        uuid_0.1-4          reprex_2.0.0       
[67] glue_1.6.1          evaluate_0.14       latticeExtra_0.6-30
[70] data.table_1.13.6   modelr_0.1.8        vctrs_0.3.8        
[73] png_0.1-7           Rttf2pt1_1.3.12     cellranger_1.1.0   
[76] gtable_0.3.0        assertthat_0.2.1    xfun_0.24          
[79] broom_0.7.6         cluster_2.1.0       ellipsis_0.3.2     

Reading data¶

In [3]:
df<-read.csv("maindata.csv")
In [4]:
head(df)
A data.frame: 6 × 15
IDChainIDGenerationExpConditionAgeGenderTrialChoiceLengthWidthThicknessFitnesserroredFitnessEarnedMoneyTimeStamp
<chr><int><int><chr><int><int><int><int><int><int><int><int><int><dbl><dbl>
1I111I201111468336437314.922.022012e+13
2I111I201221968339437314.922.022012e+13
3I111I201311968339438630.362.022012e+13
4I111I201422468342138630.362.022012e+13
5I111I201512468342141346.882.022012e+13
6I111I201622968344641346.882.022012e+13
In [5]:
colnames(df)
  1. 'ID'
  2. 'ChainID'
  3. 'Generation'
  4. 'ExpCondition'
  5. 'Age'
  6. 'Gender'
  7. 'Trial'
  8. 'Choice'
  9. 'Length'
  10. 'Width'
  11. 'Thickness'
  12. 'Fitness'
  13. 'erroredFitness'
  14. 'EarnedMoney'
  15. 'TimeStamp'
In [6]:
dim(df)
  1. 5000
  2. 15

Set Numerical ID for each participants (from 1 to 100)¶

Color coordination¶

In [7]:
rep(c(1:100),50) %>% sort() -> NumID
df<-cbind(df, NumID)
In [8]:
CPalet<-c("#117733","#6699CC","#CF6677")
show_col(CPalet)

CPalet
  1. '#117733'
  2. '#6699CC'
  3. '#CF6677'

Making Summary Efficiency¶

In [9]:
df %>% 
group_by(NumID) %>% 
  summarise(Efficiency= mean(Fitness)) -> Efficiency

df1<-df[df$Trial==1,] 
df1chosen<-df1[c("Generation","ExpCondition","ChainID", "Age", "Gender", "ID")]


cbind(
Efficiency,df1chosen) -> EfficiencyDf


 EfficiencyDf

#head(Efficiency)
#cbind(Efficiency, PptGeneration,PptCondition, PptSessionID ) 
#cbind(Efficiency, PptGeneration,PptCondition, PptSessionID ) -> EfficiencyDf

#colnames(EfficiencyDf)<-c("ID","Efficiency","Generation","ExpCondition","SessionID")
#EfficiencyDf
A data.frame: 100 × 8
NumIDEfficiencyGenerationExpConditionChainIDAgeGenderID
<int><dbl><int><chr><int><int><int><chr>
1 1673.641I 1201I1
51 2574.441I 2203I2
101 3690.861I 3213I3
151 4646.921I 4203I4
201 5548.621I 5202I5
251 6604.261I 6192I6
301 7696.341I 7203I7
351 8746.521I 8203I8
401 9710.721I 9213I9
45110750.201I10213I10
50111677.641I11213I11
55112707.821I12212I12
60113680.681I13212I13
65114708.721I14193I14
70115736.901I15213I15
75116727.501I16213I16
80117689.641I17202I17
85118704.381I18193I18
90119677.841I19193I19
95120628.821I20202I20
100121667.741O 1222O1
105122898.202O 1203O1
110123701.601O 2202O2
115124935.462O 2193O2
120125704.401O 3202O3
125126937.442O 3222O3
130127691.441O 4234O4
135128830.042O 4222O4
140129683.781O 5213O5
145130881.562O 5213O5
⋮⋮⋮⋮⋮⋮⋮⋮⋮
3501 71704.921V 6202V6
3551 72792.342V 6223V6
3601 73693.281V 7222V7
3651 74867.822V 7202V7
3701 75714.361V 8213V8
3751 76952.122V 8212V8
3801 77664.441V 9213V9
3851 78793.002V 9213V9
3901 79695.261V10202V10
3951 80848.442V10223V10
4001 81551.021V11192V11
4051 82694.702V11182V11
4101 83767.141V12193V12
4151 84934.862V12202V12
4201 85645.941V13223V13
4251 86936.382V13193V13
4301 87733.981V14203V14
4351 88914.002V14193V14
4401 89766.421V15213V15
4451 90975.002V15193V15
4501 91628.821V16193V16
4551 92934.642V16203V16
4601 93723.021V17202V17
4651 94967.102V17203V17
4701 95658.921V18192V18
4751 96880.122V18192V18
4801 97699.541V19192V19
4851 98901.942V19192V19
4901 99636.301V20203V20
4951100825.402V20222V20
In [10]:
EfficiencyDf$Generation - EfficiencyDf$Generation_backup

Exploration¶

Making Summary Data¶

  • Counting the number of exploration for each participants
In [11]:
df %>% 
group_by(NumID) %>% 
  summarise(sum_choice = sum(Choice-1)) -> Exploration

df1<-df[df$Trial==1,]

PSessionID<-df1$ChainID
PGeneration<-df1$Generation
PCondition<-df1$ExpCondition
PGender<-df1$Gender



cbind(Exploration, PGeneration,PCondition, PSessionID, PGender) -> ExpDf
colnames(ExpDf)<-c("ID","Exploration","Generation","ExpCondition","SessionID","Gender")

head(ExpDf)
A data.frame: 6 × 6
IDExplorationGenerationExpConditionSessionIDGender
<int><dbl><int><chr><int><int>
11181I11
22171I23
33211I33
44221I43
55191I52
66241I62

Visualizing exploration and exploration for each participant¶

In [12]:
library(extrafont)
In [13]:
labeli <- as_labeller(c("I" = "Asocial",
                         "O" = "Unrepaid",
                         "V" = "Repaid",
                        "1"="1","2"="2","3"="3","4"="4","5"="5","6"="6","7"="7","8"="8","9"="9","10"="10","11"="11",
                        "12"="12","13"="13","14"="14",
                        "15"="15","16"="16","17"="17","18"="18","19"="19","20"="20"))

#my_x_title <- expression(paste("Trial (", italic("T"), ")"))
my_x_title <- "Trial"


options(repr.plot.width=10, repr.plot.height=5.2)
#options(repr.plot.width=20, repr.plot.height=20)
g<-ggplot(df[df$Generation == 1, ], aes(x=Trial, y= Choice-1, color = as.factor(ExpCondition))) + 
ylim(0,1)+
theme_bw()+geom_point()+geom_line(alpha = 1, size = 0.2)+facet_grid(as.factor(ChainID)~ExpCondition ,labeller = labeli)+
theme(axis.title.y=element_blank(),
        axis.text.y=element_blank(),
        axis.ticks.y=element_blank(),
      panel.grid.major.y = element_blank(),
      panel.grid.minor.y = element_blank()
     )+ xlab(my_x_title)+ 
theme(legend.position = "none")+
scale_color_manual(values = CPalet)
g

ggsave("FiguresRev/FigExplExpr.pdf", dpi = 220, device = "pdf", width = 10, height = 5.2)
ggsave("FiguresRev/FigExplExpr.eps", dpi = 220, device = "eps", width = 10, height = 5.2)
ggsave("FiguresRev/FigExplExpr.png", dpi = 220, device = "png", width = 10, height = 5.2)
In [14]:
DF<-ExpDf[,c(1,2,3,4)] 
head(DF)
DF %>% 
    group_by(Generation, ExpCondition) %>%
  summarise(mean = mean(Exploration), SE =  sd(Exploration)/sqrt(20)) -> SmrDF

SmrDF$SE %>% round(.,3) -> SmrDF$SE 
options(warn = -1)
A data.frame: 6 × 4
IDExplorationGenerationExpCondition
<int><dbl><int><chr>
11181I
22171I
33211I
44221I
55191I
66241I
`summarise()` has grouped output by 'Generation'. You can override using the `.groups` argument.
In [15]:
#DF[(DF$Generation == 1)&(DF$ExpCondition== "I"),]$Exploration
DF[(DF$Generation == 1)&(DF$ExpCondition== "I"),]$Exploration %>%   rank(., ties.method= "first") -> orderI1
orderI1<-length(orderI1)+1-orderI1
DF[(DF$Generation == 2)&(DF$ExpCondition== "I"),]$Exploration %>%   rank(., ties.method= "first") -> orderI2
orderI2<-length(orderI2)+1-orderI2



#DF[(DF$Generation == 1)&(DF$ExpCondition== "O"),]$Exploration
DF[(DF$Generation == 1)&(DF$ExpCondition== "O"),]$Exploration %>%  rank(., ties.method= "first") -> orderO1
orderO1<-length(orderO1)+1-orderO1
DF[(DF$Generation == 2)&(DF$ExpCondition== "O"),]$Exploration %>%  rank(., ties.method= "first") -> orderO2
orderO2<-length(orderO2)+1-orderO2


#DF[(DF$Generation == 1)&(DF$ExpCondition== "V"),]$Exploration
DF[(DF$Generation == 1)&(DF$ExpCondition== "V"),]$Exploration %>%  rank(., ties.method= "first") -> orderV1
orderV1<-length(orderV1)+1-orderV1
DF[(DF$Generation == 2)&(DF$ExpCondition== "V"),]$Exploration %>%  rank(., ties.method= "first")-> orderV2
orderV2<-length(orderV2)+1-orderV2
In [16]:
Order<-df$ChainID
df<-mutate(df, Order)

df[(df$Generation == 1)&(df$ExpCondition== "I"),]$ChainID -> tempIDList
df[(df$Generation == 1)&(df$ExpCondition== "I"),]$Order<-orderI1[tempIDList] 

df[(df$Generation == 2)&(df$ExpCondition== "I"),]$ChainID -> tempIDList
df[(df$Generation == 2)&(df$ExpCondition== "I"),]$Order<-orderI2[tempIDList] 


df[(df$Generation == 1)&(df$ExpCondition== "O"),]$ChainID -> tempIDList
df[(df$Generation == 1)&(df$ExpCondition== "O"),]$Order<-orderO1[tempIDList] 

df[(df$Generation == 2)&(df$ExpCondition== "O"),]$ChainID -> tempIDList
df[(df$Generation == 2)&(df$ExpCondition== "O"),]$Order<-orderO2[tempIDList] 

df[(df$Generation == 1)&(df$ExpCondition== "V"),]$ChainID -> tempIDList
df[(df$Generation == 1)&(df$ExpCondition== "V"),]$Order<-orderV1[tempIDList] 

df[(df$Generation == 2)&(df$ExpCondition== "V"),]$ChainID -> tempIDList
df[(df$Generation == 2)&(df$ExpCondition== "V"),]$Order<-orderV2[tempIDList]
In [17]:
tempIDList[orderV1] %>% length()
20
In [18]:
df[(df$Generation == 2)&(df$ExpCondition== "V"),]$Order %>% length()
1000
In [19]:
labeli <- as_labeller(c("I" = "Asocial",
                         "O" = "Unrepaid",
                         "V" = "Repaid",
                        "1"="1","2"="2","3"="3","4"="4","5"="5","6"="6","7"="7","8"="8","9"="9","10"="10","11"="11",
                        "12"="12","13"="13","14"="14",
                        "15"="15","16"="16","17"="17","18"="18","19"="19","20"="20"))

my_x_title <- expression("Trial")

options(repr.plot.width=10, repr.plot.height=5.2)
#options(repr.plot.width=20, repr.plot.height=20)
g<-ggplot(df[df$Generation == 1, ], aes(x=Trial, y= Choice-1, color = as.factor(ExpCondition))) + 
ylim(0,1)+
theme_bw()+geom_point()+geom_line(alpha = 1, size = 0.2)+facet_grid(as.factor(Order)~ExpCondition ,labeller = labeli)+
theme(axis.title.y=element_blank(),
        axis.text.y=element_blank(),
        axis.ticks.y=element_blank(),
      panel.grid.major.y = element_blank(),
      panel.grid.minor.y = element_blank()
     )+ xlab(my_x_title)+ 
theme(legend.position = "none")+
scale_color_manual(values = CPalet)
g

ggsave("FiguresRev/FigExplExpr.pdf", dpi = 220, device = "pdf", width = 10, height = 5.2)
ggsave("FiguresRev/FigExplExpr.eps", dpi = 220, device = "eps", width = 10, height = 5.2)
ggsave("FiguresRev/FigExplExpr.png", dpi = 220, device = "png", width = 10, height = 5.2)

Making Summary Dataset¶

  • Counting the number of exploration for each participants
In [20]:
DF<-ExpDf[,c(1,2,3,4)] 
head(DF)
DF %>% 
    group_by(Generation, ExpCondition) %>%
  summarise(mean = mean(Exploration), SE =  sd(Exploration)/sqrt(20)) -> SmrDF

SmrDF$SE %>% round(.,3) -> SmrDF$SE 
options(warn = -1)
SmrDF
A data.frame: 6 × 4
IDExplorationGenerationExpCondition
<int><dbl><int><chr>
11181I
22171I
33211I
44221I
55191I
66241I
`summarise()` has grouped output by 'Generation'. You can override using the `.groups` argument.
A grouped_df: 5 × 4
GenerationExpConditionmeanSE
<int><chr><dbl><dbl>
1I20.100.784
1O19.451.243
1V24.601.437
2O11.151.190
2V10.651.575
In [21]:
#ExpDf[(ExpDf$Generation == 1)&(ExpDf$ExpCondition!= "O"),] -> JASPVI
#ExpDf[(ExpDf$Generation == 1)&(ExpDf$ExpCondition!= "V"),] -> JASPOI
#write.csv(JASPVI, file="JASPVI.csv", sep=",")
#write.csv(JASPOI, file="JASPOI.csv", sep=",")

Visualizing Summary¶

Bar graphs + Cloud Plots¶

In [22]:
y_title <- expression(paste("Exploration trials (", italic(tau), ")"))
#taulabel<-"a"
options(warn = -1)
taulabel<- expression(italic(tau)*"*")

options(repr.plot.width=6, repr.plot.height=3)

suppressMessages(
 suppressWarnings(
g <- ggplot(ExpDf[ExpDf$Generation ==1,], aes(x =as.factor(ExpCondition), y = Exploration,fill =as.factor(ExpCondition))) +
  ggdist::stat_slab( aes(x =as.numeric(as.factor(ExpCondition))+0.1),
    alpha = 0.9,
    width = .24, 
    .width = c(0.00002, .92), 
  ) + 
geom_jitter(size = 0.7,height=0, width =0.05, alpha = 0.7,aes(x = as.factor(ExpCondition), color =as.factor(ExpCondition))) +
coord_cartesian(xlim = c(1.0, NA))+theme_bw()+
scale_color_manual(values = CPalet, name = "Condition",labels = c("Asocial", "Unrepaid","Repaid"))+
scale_fill_manual(values = CPalet, name = "Condition",labels = c("Asocial", "Unrepaid","Repaid"))+
ylab(y_title )+xlab("Experimental Conition")+
scale_x_discrete("Condition", labels = c("I" = "Asocial","O" = "Unrepaid", "V" = "Repaid"))+
stat_summary(fun= mean,  geom="bar", alpha = 1, width = 0.2, color = "black",aes(x = as.numeric(as.factor(ExpCondition))-0.2)) +
stat_summary(fun.min = function(x) mean(x) -sd(x)/sqrt(length(x)), 
               fun.max = function(x) mean(x) + sd(x)/sqrt(length(x)), 
               geom = "errorbar", width =0.05, aes(x = as.numeric(as.factor(ExpCondition))-0.2))+
 geom_segment(aes(x=0.6,xend=1.22,y=(Generation-1)*12,yend=(Generation-1)*12),linetype=2, color = "grey39", size = 0.4)+
 geom_segment(aes(x=1.6,xend=2.22,y=(Generation-1)*12,yend=(Generation-1)*12),linetype=2, color = "grey39", size = 0.4)+
 geom_segment(aes(x=2.6,xend=3.22,y=(Generation-1)*22,yend=(Generation-1)*22),linetype=2, color = "grey39", size = 0.4)+
annotate("text",x=1.3,y=0.01+12,label=taulabel) +
annotate("text",x=2.3,y=0.01+12,label=taulabel) +
annotate("text",x=3.3,y=0.01+22,label=taulabel) 
     ))

suppressMessages(
 suppressWarnings(g)
    )


 ggsave("Figures/MFreqExpo.pdf", dpi = 220, device = "pdf", width = 5, height =3)

Bar Graph¶

In [23]:
y_title <- expression(paste("Mean exploration rate (", italic("W/T"), ")"))


labeli <- as_labeller(c("I" = "Asocial",
                         "O" = "Unnrepaid",
                         "V" = "Repaid",
                        "1"="First Generation","2"="Second Generation"))

options(repr.plot.width=5, repr.plot.height=3)
ggplot(SmrDF, aes(y=mean, x=ExpCondition,fill=ExpCondition))+
  geom_bar(stat = "identity", width = 0.4 , color = "black")+theme_bw()+
  geom_errorbar(aes(ymax = mean + SE, ymin = mean - SE), width = 0.1)+
                facet_grid(Generation~., labeller = labeli )+
scale_fill_manual(values = CPalet, name = "Condition",labels = c("Asocial", "Unrepaid","Repaid"))+
ylab(y_title )+xlab("Experimental Conition")+
scale_x_discrete("Condition", labels = c("I" = "Asocial","O" = "Unrepaid", "V" = "Repaid"))


#ggsave("MExpRate.pdf", dpi = 220, device = "pdf", width = 5, height =3)
In [24]:
y_title <- expression(paste("Exploration trials (", italic(tau), ")"))
#taulabel<-"a"
options(warn = -1)

taulabel<- expression(italic(tau)*"*")

options(repr.plot.width=6, repr.plot.height=3)

suppressMessages(
 suppressWarnings(
g <- ggplot(ExpDf[ExpDf$Generation ==1,], aes(x =as.factor(ExpCondition), y = Exploration,fill =as.factor(ExpCondition))) +
  ggdist::stat_slab( aes(x =as.numeric(as.factor(ExpCondition))+0.1),
    alpha = 0.9,
    width = .24, 
    .width = c(0.00002, .92), 
  ) + 
geom_jitter(size = 0.7,height=0, width =0.05, alpha = 0.7,aes(x = as.factor(ExpCondition), color =as.factor(ExpCondition))) +
coord_cartesian(xlim = c(1.0, NA))+theme_bw()+
scale_color_manual(values = CPalet, name = "Condition",labels = c("Asocial", "Unrepaid","Repaid"))+
scale_fill_manual(values = CPalet, name = "Condition",labels = c("Asocial", "Unrepaid","Repaid"))+
ylab(y_title )+xlab("Experimental Conition")+
scale_x_discrete("Condition", labels = c("I" = "Asocial","O" = "Unrepaid", "V" = "Repaid"))+
#stat_summary(fun= mean,  geom="bar", alpha = 1, width = 0.2, color = "black",aes(x = as.numeric(as.factor(ExpCondition))-0.2)) +
geom_boxplot(alpha=0.7, width =0.2, aes(x = as.numeric(as.factor(ExpCondition))-0.2))+
 geom_segment(aes(x=0.6,xend=1.22,y=12,yend=12),linetype=2, color = "grey39", size = 0.4)+
 geom_segment(aes(x=1.6,xend=2.22,y=12,yend=12),linetype=2, color = "grey39", size = 0.4)+
 geom_segment(aes(x=2.6,xend=3.22,y=22,yend=22),linetype=2, color = "grey39", size = 0.4)+
     stat_summary(fun= mean,  geom="point", size = 2.5, shape = 18 ,alpha = 1, width = 0.2, color = "black",aes(x = as.numeric(as.factor(ExpCondition))-0.2)) +
stat_summary(fun.min = function(x) mean(x) -sd(x)/sqrt(length(x)), 
              fun.max = function(x) mean(x) + sd(x)/sqrt(length(x)), 
              geom = "errorbar", width =0.05, aes(x = as.numeric(as.factor(ExpCondition))-0.2))+
annotate("text",x=1.3,y=0.01+12,label=taulabel) +
annotate("text",x=2.3,y=0.01+12,label=taulabel) +
annotate("text",x=3.3,y=0.01+22,label=taulabel) 
     ))

suppressMessages(
 suppressWarnings(g)
    )


 ggsave("Figures/MFreqExpoR1.pdf", dpi = 220, device = "pdf", width = 5, height =3)
 ggsave("Figures/MFreqExpoR1.png", dpi = 220, device = "png", width = 5, height =3)
In [25]:
options(warn = -1)
y_title <- expression(paste("Exploration trials (", italic(tau), ")"))
#taulabel<-"a"

taulabel<- expression(italic(tau)*"*")

options(repr.plot.width=6, repr.plot.height=3)

suppressMessages(
 suppressWarnings(
g <- ggplot(ExpDf[ExpDf$Generation ==1,], aes(x =as.factor(ExpCondition), y = Exploration,fill =as.factor(ExpCondition))) +
  ggdist::stat_slab( aes(x =as.numeric(as.factor(ExpCondition))+0.1),
    alpha = 0.9,
    width = .24, 
    .width = c(0.00002, .92), 
  ) + 
geom_jitter(size = 0.7,height=0, width =0.05, alpha = 0.7,aes(x = as.factor(ExpCondition), color =as.factor(ExpCondition))) +
coord_cartesian(xlim = c(1.0, NA))+theme_bw()+
scale_color_manual(values = CPalet, name = "Condition",labels = c("Asocial", "Unrepaid","Repaid"))+
scale_fill_manual(values = CPalet, name = "Condition",labels = c("Asocial", "Unrepaid","Repaid"))+
ylab(y_title )+xlab("Experimental Conition")+
scale_x_discrete("Condition", labels = c("I" = "Asocial","O" = "Unrepaid", "V" = "Repaid"))+
#stat_summary(fun= mean,  geom="bar", alpha = 1, width = 0.2, color = "black",aes(x = as.numeric(as.factor(ExpCondition))-0.2)) +
geom_boxplot(alpha=0.7, width =0.2, aes(x = as.numeric(as.factor(ExpCondition))-0.2))+
 geom_segment(aes(x=0.6,xend=1.22,y=12,yend=12),linetype=2, color = "grey39", size = 0.4)+
 geom_segment(aes(x=1.6,xend=2.22,y=12,yend=12),linetype=2, color = "grey39", size = 0.4)+
 geom_segment(aes(x=2.6,xend=3.22,y=22,yend=22),linetype=2, color = "grey39", size = 0.4)+
      geom_segment(aes(x=1,xend=3,y=43,yend=43),linetype=1, color = "grey39", size = 0.2)+
     geom_segment(aes(x=1,xend=1,y=41,yend=43),linetype=1, color = "grey39", size = 0.2)+
          geom_segment(aes(x=3,xend=3,y=41,yend=43),linetype=1, color = "grey39", size = 0.2)+
      geom_segment(aes(x=1,xend=2,y=33,yend=33),linetype=1, color = "grey39", size = 0.2)+
     geom_segment(aes(x=1,xend=1,y=31,yend=33),linetype=1, color = "grey39", size = 0.2)+
          geom_segment(aes(x=2,xend=2,y=31,yend=33),linetype=1, color = "grey39", size = 0.2)+
     stat_summary(fun= mean,  geom="point", size = 2.5, shape = 18 ,alpha = 1, width = 0.2, color = "black",aes(x = as.numeric(as.factor(ExpCondition))-0.2)) +
stat_summary(fun.min = function(x) mean(x) -sd(x)/sqrt(length(x)), 
              fun.max = function(x) mean(x) + sd(x)/sqrt(length(x)), 
              geom = "errorbar", width =0.05, aes(x = as.numeric(as.factor(ExpCondition))-0.2))+
annotate("text",x=1.3,y=0.01+12,label=taulabel) +
annotate("text",x=2.3,y=0.01+12,label=taulabel) +
annotate("text",x=3.3,y=0.01+22,label=taulabel) +
     annotate("text",x=2,y=45,label="* (p = 0.010)") +
      annotate("text",x=1.5,y=34.5,label="NS (p = 0.661)") 
     ))

suppressMessages(
 suppressWarnings(g)
    )


 ggsave("Figures/MFreqExpoR1_sig.pdf", dpi = 220, device = "pdf", width = 5, height =3)
 ggsave("Figures/MFreqExpoR1_sig.png", dpi = 220, device = "png", width = 5, height =3)
In [26]:
options(warn = -1)
y_title <- expression(paste("Exploration trials (", italic(tau), ")"))
#taulabel<-"a"

taulabel<- expression(italic(tau)*"*")

options(repr.plot.width=6, repr.plot.height=3)

suppressMessages(
 suppressWarnings(
g <- ggplot(ExpDf[ExpDf$Generation ==1,], aes(x =as.factor(ExpCondition), y = Exploration,fill =as.factor(ExpCondition))) +
  ggdist::stat_slab( aes(x =as.numeric(as.factor(ExpCondition))+0.1),
    alpha = 0.9,
    width = .24, 
    .width = c(0.00002, .92), 
  ) + 
geom_jitter(size = 0.7,height=0, width =0.05, alpha = 0.7,aes(x = as.factor(ExpCondition), color =as.factor(ExpCondition))) +
coord_cartesian(xlim = c(1.0, NA))+theme_bw()+
scale_color_manual(values = CPalet, name = "Condition",labels = c("Asocial", "Unrepaid","Repaid"))+
scale_fill_manual(values = CPalet, name = "Condition",labels = c("Asocial", "Unrepaid","Repaid"))+
ylab(y_title )+xlab("Experimental Conition")+
scale_x_discrete("Condition", labels = c("I" = "Asocial","O" = "Unrepaid", "V" = "Repaid"))+
#stat_summary(fun= mean,  geom="bar", alpha = 1, width = 0.2, color = "black",aes(x = as.numeric(as.factor(ExpCondition))-0.2)) +
geom_boxplot(alpha=0.7, width =0.2, aes(x = as.numeric(as.factor(ExpCondition))-0.2))+
 geom_segment(aes(x=0.6,xend=1.22,y=12,yend=12),linetype=2, color = "grey39", size = 0.4)+
 geom_segment(aes(x=1.6,xend=2.22,y=12,yend=12),linetype=2, color = "grey39", size = 0.4)+
 geom_segment(aes(x=2.6,xend=3.22,y=22,yend=22),linetype=2, color = "grey39", size = 0.4)+
      geom_segment(aes(x=1,xend=3,y=43,yend=43),linetype=1, color = "grey39", size = 0.2)+
     geom_segment(aes(x=1,xend=1,y=41,yend=43),linetype=1, color = "grey39", size = 0.2)+
          geom_segment(aes(x=3,xend=3,y=41,yend=43),linetype=1, color = "grey39", size = 0.2)+
      geom_segment(aes(x=1,xend=2,y=33,yend=33),linetype=1, color = "grey39", size = 0.2)+
     geom_segment(aes(x=1,xend=1,y=31,yend=33),linetype=1, color = "grey39", size = 0.2)+
          geom_segment(aes(x=2,xend=2,y=31,yend=33),linetype=1, color = "grey39", size = 0.2)+
     stat_summary(fun= mean,  geom="point", size = 2.5, shape = 18 ,alpha = 1, width = 0.2, color = "black",aes(x = as.numeric(as.factor(ExpCondition))-0.2)) +
stat_summary(fun.min = function(x) mean(x) -sd(x)/sqrt(length(x)), 
              fun.max = function(x) mean(x) + sd(x)/sqrt(length(x)), 
              geom = "errorbar", width =0.05, aes(x = as.numeric(as.factor(ExpCondition))-0.2))+
annotate("text",x=1.3,y=0.01+12,label=taulabel) +
annotate("text",x=2.3,y=0.01+12,label=taulabel) +
annotate("text",x=3.3,y=0.01+22,label=taulabel) +
     annotate("text",x=2,y=43,label="*", size = 5) +
      annotate("text",x=1.5,y=34.5,label="NS", size = 2.5) 
     ))

suppressMessages(
 suppressWarnings(g)
    )


 ggsave("Figures/MFreqExpoR1_sig1.pdf", dpi = 220, device = "pdf", width = 5, height =3)
 ggsave("Figures/MFreqExpoR1_sig1.png", dpi = 220, device = "png", width = 5, height =3)
In [27]:
y_title <- expression(paste("Exploration trials (", italic(tau), ")"))
#taulabel<-"a"

taulabel<- expression(italic(tau)*"*")

options(repr.plot.width=6, repr.plot.height=6)

suppressMessages(
 suppressWarnings(
g <- ggplot(ExpDf, aes(x =as.factor(ExpCondition), y = Exploration,fill =as.factor(ExpCondition))) +
  ggdist::stat_slab( aes(x =as.numeric(as.factor(ExpCondition))+0.1),
    alpha = 0.9,
    width = .24, 
    .width = c(0.00002, .92), 
  ) + 
geom_jitter(size = 0.7,height=0, width =0.05, alpha = 0.7,aes(x = as.factor(ExpCondition), color =as.factor(ExpCondition))) +
coord_cartesian(xlim = c(1.0, NA))+theme_bw()+
scale_color_manual(values = CPalet, name = "Condition",labels = c("Asocial", "Unrepaid","Repaid"))+
scale_fill_manual(values = CPalet, name = "Condition",labels = c("Asocial", "Unrepaid","Repaid"))+
ylab(y_title )+xlab("Experimental Conition")+
scale_x_discrete("Condition", labels = c("I" = "Asocial","O" = "Unrepaid", "V" = "Repaid"))+
#stat_summary(fun= mean,  geom="bar", alpha = 1, width = 0.2, color = "black",aes(x = as.numeric(as.factor(ExpCondition))-0.2)) +
geom_boxplot(alpha=0.7, width =0.2, aes(x = as.numeric(as.factor(ExpCondition))-0.2))+
# geom_segment(aes(x=0.6,xend=1.22,y=12,yend=12),linetype=2, color = "grey39", size = 0.4)+
# geom_segment(aes(x=1.6,xend=2.22,y=12,yend=12),linetype=2, color = "grey39", size = 0.4)+
# geom_segment(aes(x=2.6,xend=3.22,y=22,yend=22),linetype=2, color = "grey39", size = 0.4)+
     stat_summary(fun= mean,  geom="point", size = 3, shape = 18 , alpha = 1, width = 0.2, color = "black",aes(x = as.numeric(as.factor(ExpCondition))-0.2)) +
stat_summary(fun.min = function(x) mean(x) -sd(x)/sqrt(length(x)), 
              fun.max = function(x) mean(x) + sd(x)/sqrt(length(x)), 
              geom = "errorbar", width =0.05, aes(x = as.numeric(as.factor(ExpCondition))-0.2))+
                facet_grid(Generation~., labeller = labeli )
     #+
#annotate("text",x=1.3,y=0.01+12,label=taulabel) +
#annotate("text",x=2.3,y=0.01+12,label=taulabel) +
#annotate("text",x=3.3,y=0.01+22,label=taulabel) 
 
 ))

suppressMessages(
 suppressWarnings(g)
    )


 ggsave("Figures/MFreqExpo2Gen.png", dpi = 220, device = "png", width = 5, height =3)

 ggsave("Figures/MFreqExpo2Gen.pdf", dpi = 220, device = "pdf", width = 5, height =3)
In [28]:
y_title <- expression(paste("Exploration trials (", italic(tau), ")"))
#taulabel<-"a"

taulabel<- expression(italic(tau)*"*")

options(repr.plot.width=6.5, repr.plot.height=3)

suppressMessages(
 suppressWarnings(
g <- ggplot(ExpDf, aes(x =as.factor(ExpCondition), y = Exploration,fill =as.factor(ExpCondition))) +
  ggdist::stat_slab( aes(x =as.numeric(as.factor(ExpCondition))+0.1),
    alpha = 0.9,
    width = .24, 
    .width = c(0.00002, .92), 
  ) + 
geom_jitter(size = 0.7,height=0, width =0.05, alpha = 0.7,aes(x = as.factor(ExpCondition), color =as.factor(ExpCondition))) +
coord_cartesian(xlim = c(1.0, NA))+theme_bw()+
scale_color_manual(values = CPalet, name = "Condition",labels = c("Asocial", "Unrepaid","Repaid"))+
scale_fill_manual(values = CPalet, name = "Condition",labels = c("Asocial", "Unrepaid","Repaid"))+
ylab(y_title )+xlab("Experimental Conition")+
scale_x_discrete("Condition", labels = c("I" = "Asocial","O" = "Unrepaid", "V" = "Repaid"))+
#stat_summary(fun= mean,  geom="bar", alpha = 1, width = 0.2, color = "black",aes(x = as.numeric(as.factor(ExpCondition))-0.2)) +
geom_boxplot(alpha=0.7, width =0.2, aes(x = as.numeric(as.factor(ExpCondition))-0.2))+
 geom_segment(aes(x=0.6,xend=1.22,y=(-1*Generation+2)*12,yend=(-1*Generation+2)*12),linetype=2, color = "grey39", size = 0.4)+
 geom_segment(aes(x=1.6,xend=2.22,y=(-1*Generation+2)*12,yend=(-1*Generation+2)*12),linetype=2, color = "grey39", size = 0.4)+
 geom_segment(aes(x=2.6,xend=3.22,y=(-1*Generation+2)*22,yend=(-1*Generation+2)*22),linetype=2, color = "grey39", size = 0.4)+
     stat_summary(fun= mean,  geom="point", size = 3, shape = 18 , alpha = 1, width = 0.2, color = "black",aes(x = as.numeric(as.factor(ExpCondition))-0.2)) +
     stat_summary(fun.min = function(x) mean(x) -sd(x)/sqrt(length(x)), 
              fun.max = function(x) mean(x) + sd(x)/sqrt(length(x)), 
              geom = "errorbar", width =0.05, aes(x = as.numeric(as.factor(ExpCondition))-0.2))+
#annotate("text",x=1.3,y=0.01+(-1*Generation+2)*12,label=taulabel) +
#annotate("text",x=2.3,y=0.01+(-1*Generation+2)*12,label=taulabel) +
#annotate("text",x=3.3,y=0.01+(-1*Generation+2)*22,label=taulabel) +
                facet_grid(.~Generation, labeller = labeli )
     #+
#annotate("text",x=1.3,y=0.01+12,label=taulabel) +
#annotate("text",x=2.3,y=0.01+12,label=taulabel) +
#annotate("text",x=3.3,y=0.01+22,label=taulabel) 
 
 ))

suppressMessages(
 suppressWarnings(g)
    )

ggsave("Figures/MFreqExpo2Gen.png", dpi = 220, device = "png", width = 6.5, height =3)
ggsave("Figures/MFreqExpo2Gen.pdf", dpi = 220, device = "pdf", width = 6.5, height =3)
In [29]:
y_title <- expression(paste("Exploration trials (", italic(tau), ")"))
#taulabel<-"a"

taulabel<- expression(italic(tau)*"*")


options(repr.plot.width=9, repr.plot.height=3)

suppressMessages(
 suppressWarnings(
g <- ggplot(ExpDf, aes(x =as.factor(ExpCondition), y = Exploration,fill =as.factor(ExpCondition))) +
  ggdist::stat_slab( aes(x =as.numeric(as.factor(ExpCondition))+0.1),
    alpha = 0.9,
    width = .24, 
    .width = c(0.00002, .92), 
  ) + 
geom_jitter(size = 0.7,height=0, width =0.05, alpha = 0.7,aes(x = as.factor(ExpCondition), color =as.factor(ExpCondition))) +
coord_cartesian(xlim = c(1.0, NA))+theme_bw()+
scale_color_manual(values = CPalet, name = "Condition",labels = c("Asocial", "Unrepaid","Repaid"))+
scale_fill_manual(values = CPalet, name = "Condition",labels = c("Asocial", "Unrepaid","Repaid"))+
ylab(y_title)+xlab("Experimental Conition")+
scale_x_discrete("Condition", labels = c("I" = "Asocial","O" = "Unrepaid", "V" = "Repaid"))+
#stat_summary(fun= mean,  geom="bar", alpha = 1, width = 0.2, color = "black",aes(x = as.numeric(as.factor(ExpCondition))-0.2)) +
geom_boxplot(alpha=0.7, width =0.2, aes(x = as.numeric(as.factor(ExpCondition))-0.2))+
# geom_segment(aes(x=0.6,xend=1.22,y=12,yend=12),linetype=2, color = "grey39", size = 0.4)+
# geom_segment(aes(x=1.6,xend=2.22,y=12,yend=12),linetype=2, color = "grey39", size = 0.4)+
# geom_segment(aes(x=2.6,xend=3.22,y=22,yend=22),linetype=2, color = "grey39", size = 0.4)+
     stat_summary(fun= mean,  geom="point", size = 3, shape = 18 , alpha = 1, width = 0.2, color = "black",aes(x = as.numeric(as.factor(ExpCondition))-0.2)) +
stat_summary(fun.min = function(x) mean(x) -sd(x)/sqrt(length(x)), 
              fun.max = function(x) mean(x) + sd(x)/sqrt(length(x)), 
              geom = "errorbar", width =0.05, aes(x = as.numeric(as.factor(ExpCondition))-0.2))+
                facet_grid(.~Generation, labeller = labeli )
     #+
#annotate("text",x=1.3,y=0.01+12,label=taulabel) +
#annotate("text",x=2.3,y=0.01+12,label=taulabel) +
#annotate("text",x=3.3,y=0.01+22,label=taulabel) 
 
 ))

suppressMessages(
 suppressWarnings(g)
    )


ggsave("Figures/MFreqExpo2Gen.png", dpi = 220, device = "png", width = 6.5, height =3)
ggsave("Figures/MFreqExpo2Gen.pdf", dpi = 220, device = "pdf", width = 6.5, height =3)
In [ ]:

t-tests¶

Preparation¶

In [30]:
"IND"
ExpDf[(ExpDf$Generation == 1)&(ExpDf$ExpCondition == "I"),]$Exploration -> IND_Expo
round(psych::describe( IND_Expo),2)

"OBL"
ExpDf[(ExpDf$Generation == 1)&(ExpDf$ExpCondition == "O"),]$Exploration -> OBL_Expo
round(psych::describe( OBL_Expo),2)

"VER"
ExpDf[(ExpDf$Generation == 1)&(ExpDf$ExpCondition == "V"),]$Exploration -> VER_Expo
round(psych::describe( VER_Expo),2)
'IND'
A psych: 1 × 13
varsnmeansdmediantrimmedmadminmaxrangeskewkurtosisse
<dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl>
X112020.13.5119203.711527120.34-1.110.78
'OBL'
A psych: 1 × 13
varsnmeansdmediantrimmedmadminmaxrangeskewkurtosisse
<dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl>
X112019.455.562019.815.9382719-0.41-0.991.24
'VER'
A psych: 1 × 13
varsnmeansdmediantrimmedmadminmaxrangeskewkurtosisse
<dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl>
X112024.66.432424.625.19123725-0.07-0.531.44

Nonrepaid(OBL) vs. Asocial(IND)¶

In [31]:
t.test(OBL_Expo, IND_Expo)
effsize::cohen.d(OBL_Expo, IND_Expo)

"Non-Repaid SD"
round(sd(IND_Expo),2)
"Asocial SD"
round(sd(VER_Expo),2)
	Welch Two Sample t-test

data:  OBL_Expo and IND_Expo
t = -0.44228, df = 32.064, p-value = 0.6613
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -3.643344  2.343344
sample estimates:
mean of x mean of y 
    19.45     20.10 
Cohen's d

d estimate: -0.139862 (negligible)
95 percent confidence interval:
     lower      upper 
-0.7808138  0.5010898 
'Non-Repaid SD'
3.51
'Asocial SD'
6.43

Repaid(VER) vs. Asocial(IND)¶

In [32]:
library(effsize)
t.test(VER_Expo, IND_Expo)
effsize::cohen.d(VER_Expo, IND_Expo)

"Repaid SD"
round(sd(IND_Expo),2)
"Asocial SD"
round(sd(VER_Expo),2)
	Welch Two Sample t-test

data:  VER_Expo and IND_Expo
t = 2.7485, df = 29.398, p-value = 0.01013
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 1.153453 7.846547
sample estimates:
mean of x mean of y 
     24.6      20.1 
Cohen's d

d estimate: 0.8691655 (large)
95 percent confidence interval:
    lower     upper 
0.1994516 1.5388794 
'Repaid SD'
3.51
'Asocial SD'
6.43
In [ ]:

In [33]:
#"IND"
#ExpDf[(ExpDf$Generation == 2)&(ExpDf$ExpCondition == "I"),]$Exploration -> IND_Expo2nd
#round(psych::describe( IND_Expo2nd),2)

"OBL"
ExpDf[(ExpDf$Generation == 2)&(ExpDf$ExpCondition == "O"),]$Exploration -> OBL_Expo2nd
round(psych::describe( OBL_Expo2nd),2)

"VER"
ExpDf[(ExpDf$Generation == 2)&(ExpDf$ExpCondition == "V"),]$Exploration -> VER_Expo2nd
round(psych::describe( VER_Expo2nd),2)
'OBL'
A psych: 1 × 13
varsnmeansdmediantrimmedmadminmaxrangeskewkurtosisse
<dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl>
X112011.155.321011.125.93121200.06-1.081.19
'VER'
A psych: 1 × 13
varsnmeansdmediantrimmedmadminmaxrangeskewkurtosisse
<dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl>
X112010.657.0411.510.758.1502121-0.24-1.351.57
In [34]:
t.test(OBL_Expo2nd, OBL_Expo, paired=TRUE )
	Paired t-test

data:  OBL_Expo2nd and OBL_Expo
t = -4.169, df = 19, p-value = 0.0005209
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -12.467002  -4.132998
sample estimates:
mean of the differences 
                   -8.3 
In [35]:
effsize::cohen.d(OBL_Expo2nd, OBL_Expo, paired=TRUE)
Cohen's d

d estimate: -1.525274 (large)
95 percent confidence interval:
     lower      upper 
-2.6146204 -0.4359282 
In [36]:
t.test(VER_Expo2nd, VER_Expo, paired=TRUE )
	Paired t-test

data:  VER_Expo2nd and VER_Expo
t = -5.7703, df = 19, p-value = 1.467e-05
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -19.010015  -8.889985
sample estimates:
mean of the differences 
                 -13.95 
In [37]:
effsize::cohen.d(VER_Expo2nd, VER_Expo, paired=TRUE)
Cohen's d

d estimate: -2.070038 (large)
95 percent confidence interval:
     lower      upper 
-3.3574460 -0.7826294 
In [38]:
t.test(OBL_Expo2nd, VER_Expo2nd, paired=FALSE )
	Welch Two Sample t-test

data:  OBL_Expo2nd and VER_Expo2nd
t = 0.25326, df = 35.368, p-value = 0.8015
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -3.506432  4.506432
sample estimates:
mean of x mean of y 
    11.15     10.65 
In [39]:
effsize::cohen.d(OBL_Expo2nd, VER_Expo2nd)
Cohen's d

d estimate: 0.0800884 (negligible)
95 percent confidence interval:
     lower      upper 
-0.5603378  0.7205146 

Second Generation: OBL(unrepaid) vs. VER(repaid)¶

In [40]:
"OBL2"
ExpDf[(ExpDf$Generation == 2)&(ExpDf$ExpCondition == "O"),]$Exploration -> OBL_Expo2
round(psych::describe( OBL_Expo2),2)

"VER2"
ExpDf[(ExpDf$Generation == 2)&(ExpDf$ExpCondition == "V"),]$Exploration -> VER_Expo2
round(psych::describe( VER_Expo2),2)
'OBL2'
A psych: 1 × 13
varsnmeansdmediantrimmedmadminmaxrangeskewkurtosisse
<dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl>
X112011.155.321011.125.93121200.06-1.081.19
'VER2'
A psych: 1 × 13
varsnmeansdmediantrimmedmadminmaxrangeskewkurtosisse
<dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl>
X112010.657.0411.510.758.1502121-0.24-1.351.57
In [41]:
library(effsize)
t.test(OBL_Expo2, VER_Expo2)
effsize::cohen.d(OBL_Expo2, VER_Expo2)

"Repaid SD"
round(sd(OBL_Expo2),2)
"Asocial SD"
round(sd(VER_Expo2),2)
	Welch Two Sample t-test

data:  OBL_Expo2 and VER_Expo2
t = 0.25326, df = 35.368, p-value = 0.8015
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -3.506432  4.506432
sample estimates:
mean of x mean of y 
    11.15     10.65 
Cohen's d

d estimate: 0.0800884 (negligible)
95 percent confidence interval:
     lower      upper 
-0.5603378  0.7205146 
'Repaid SD'
5.32
'Asocial SD'
7.04

Parameter Shifts¶

In [42]:
df
A data.frame: 5000 × 17
IDChainIDGenerationExpConditionAgeGenderTrialChoiceLengthWidthThicknessFitnesserroredFitnessEarnedMoneyTimeStampNumIDOrder
<chr><int><int><chr><int><int><int><int><int><int><int><int><int><dbl><dbl><int><dbl>
I111I201 1114 683364373 14.922.022012e+13116
I111I201 2219 683394373 14.922.022012e+13116
I111I201 3119 683394386 30.362.022012e+13116
I111I201 4224 683421386 30.362.022012e+13116
I111I201 5124 683421413 46.882.022012e+13116
I111I201 6229 683446413 46.882.022012e+13116
I111I201 7129 683446446 64.722.022012e+13116
I111I201 8234 683467446 64.722.022012e+13116
I111I201 9134 683467466 83.362.022012e+13116
I111I20110234 678497466 83.362.022012e+13116
I111I20111134 678497502103.442.022012e+13116
I111I20112234 673525502103.442.022012e+13116
I111I20113134 673525516124.082.022012e+13116
I111I20114234 668551516124.082.022012e+13116
I111I20115134 668551549146.042.022012e+13116
I111I20116234 663574549146.042.022012e+13116
I111I20117134 663574579169.202.022012e+13116
I111I20118234 658596579169.202.022012e+13116
I111I20119134 658596598193.122.022012e+13116
I111I20120234 653615598193.122.022012e+13116
I111I20121134 653615615217.722.022012e+13116
I111I20122234 648632615217.722.022012e+13116
I111I20123134 648632623242.642.022012e+13116
I111I20124239 648651623242.642.022012e+13116
I111I20125139 648651639268.202.022012e+13116
I111I201262391148704639268.202.022012e+13116
I111I201271391148704710296.602.022012e+13116
I111I201281391148704716325.242.022012e+13116
I111I201292391648750716325.242.022012e+13116
I111I201301391648750745355.042.022012e+13116
⋮⋮⋮⋮⋮⋮⋮⋮⋮⋮⋮⋮⋮⋮⋮⋮⋮
V20202V222212704673833809 325.202.022021e+131008
V20202V222221704673833840 358.802.022021e+131008
V20202V222231704673833835 392.202.022021e+131008
V20202V222242704173827835 392.202.022021e+131008
V20202V222251704173827821 425.042.022021e+131008
V20202V222262704373830821 425.042.022021e+131008
V20202V222271704373830817 457.722.022021e+131008
V20202V222281704373830820 490.522.022021e+131008
V20202V222291704373830836 523.962.022021e+131008
V20202V222301704373830831 557.202.022021e+131008
V20202V222311704373830832 590.482.022021e+131008
V20202V222321704373830829 623.642.022021e+131008
V20202V222331704373830821 656.482.022021e+131008
V20202V222341704373830834 689.842.022021e+131008
V20202V222351704373830831 723.082.022021e+131008
V20202V222361704373830837 756.562.022021e+131008
V20202V222371704373830829 789.722.022021e+131008
V20202V222381704373830824 822.682.022021e+131008
V20202V222391704373830835 856.082.022021e+131008
V20202V222401704373830829 889.242.022021e+131008
V20202V222411704373830827 922.322.022021e+131008
V20202V222421704373830828 955.442.022021e+131008
V20202V222431704373830831 988.682.022021e+131008
V20202V2224417043738308311021.922.022021e+131008
V20202V2224517043738308301055.122.022021e+131008
V20202V2224617043738308271088.202.022021e+131008
V20202V2224717043738308261121.242.022021e+131008
V20202V2224817043738308331154.562.022021e+131008
V20202V2224917043738308331187.882.022021e+131008
V20202V2225017043738308221220.762.022021e+131008
In [43]:
## Detecting Over Explorer
In [44]:
LengthOptimal <- 70
WidthOptimal <-48
ThicknessOptimal<-11


OverExpLength<-(df$Length > LengthOptimal)+0 
OverExpWidth<-(df$Width > WidthOptimal)+0 
OverExpThickness<-(df$Thickness < ThicknessOptimal)+0

df<-dplyr::mutate(df, OverExpLength)
df<-dplyr::mutate(df, OverExpWidth)
df<-dplyr::mutate(df, OverExpThickness)
In [45]:
df[(df$Length > LengthOptimal)&(df$Generation == 1),]$NumID %>% unique() -> OverLengthIDG1
df[(df$Width > WidthOptimal)&(df$Generation == 1),]$NumID %>% unique() -> OverWidthIDG1
df[(df$Thickness < ThicknessOptimal)&(df$Generation == 1),]$NumID %>% unique() -> OverThicknessIDG1

df[(df$Length > LengthOptimal)&(df$Generation == 2),]$NumID %>% unique() -> OverLengthIDG2
df[(df$Width > WidthOptimal)&(df$Generation == 2),]$NumID %>% unique() -> OverWidthIDG2
df[(df$Thickness < ThicknessOptimal)&(df$Generation == 2),]$NumID %>% unique() -> OverThicknessIDG2

"L, G1"
OverLengthIDG1
length(OverLengthIDG1)
"W, G1"
OverWidthIDG1
length(OverWidthIDG1)
"T, G1"
OverThicknessIDG1
length(OverThicknessIDG1)

"Total, G1"
c(OverLengthIDG1, OverWidthIDG1, OverThicknessIDG1) %>%  unique() 
c(OverLengthIDG1, OverWidthIDG1, OverThicknessIDG1) %>%  unique()  %>% length()


OverLengthIDG2
OverWidthIDG2
OverThicknessIDG2
'L, G1'
  1. 4
  2. 17
  3. 71
  4. 73
  5. 83
  6. 85
6
'W, G1'
  1. 4
  2. 15
  3. 17
  4. 21
  5. 25
  6. 61
  7. 63
  8. 65
  9. 71
  10. 73
  11. 81
  12. 89
  13. 95
  14. 97
14
'T, G1'
49
1
'Total, G1'
  1. 4
  2. 17
  3. 71
  4. 73
  5. 83
  6. 85
  7. 15
  8. 21
  9. 25
  10. 61
  11. 63
  12. 65
  13. 81
  14. 89
  15. 95
  16. 97
  17. 49
17
  1. 22
  2. 26
  3. 30
  4. 38
  5. 42
  6. 54
  7. 60
  8. 72
  9. 74
  10. 84
  11. 86
  12. 96
  13. 98
  14. 100
  1. 22
  2. 26
  3. 32
  4. 36
  5. 40
  6. 44
  7. 54
  8. 56
  9. 58
  10. 60
  11. 62
  12. 66
  13. 70
  14. 72
  15. 74
  16. 76
  17. 80
  18. 82
  19. 84
  20. 90
  21. 92
  22. 96
  23. 98
  24. 100
  1. 50
  2. 74

Counting Over Exploration¶

In [46]:
"Geneartion1"
"L,W,T"
df[(df$Length > LengthOptimal)&(df$Generation == 1),]$ID %>% unique() ->OLIDG1
df[(df$Width > WidthOptimal)&(df$Generation == 1),]$ID %>% unique() ->OWIDG1
df[(df$Thickness < ThicknessOptimal)&(df$Generation == 1),]$ID %>% unique() -> OTIDG1

OLIDG1
OWIDG1
OTIDG1
c(OLIDG1,OWIDG1,OTIDG1)%>% unique()  -> AllIDG1
#c(OLIDG1,OWIDG1,OTIDG1)%>% unique() %>% length


OverIndNG1 <- str_detect(AllIDG1, pattern="I") %>% sum()
OverOblNG1 <- str_detect(AllIDG1, pattern="O") %>% sum()
OverVerNG1 <- str_detect(AllIDG1, pattern="V") %>% sum()


OverExpSummaryG1<-c(OverIndNG1 , OverOblNG1, OverVerNG1)
OverExpSummaryG1



"Geneartion2"
"L,W,T"
df[(df$Length > LengthOptimal)&(df$Generation == 2),]$ID %>% unique() ->OLIDG2
df[(df$Width > WidthOptimal)&(df$Generation == 2),]$ID %>% unique() ->OWIDG2
df[(df$Thickness < ThicknessOptimal)&(df$Generation == 2),]$ID %>% unique() -> OTIDG2

OLIDG2
OWIDG2
OTIDG2
c(OLIDG2,OWIDG2,OTIDG2)%>% unique()  -> AllIDG2
#c(OLIDG2,OWIDG2,OTIDG2)%>% unique() %>% length


OverIndNG2<- str_detect(AllIDG2, pattern="I") %>% sum()
OverOblNG2 <- str_detect(AllIDG2, pattern="O") %>% sum()
OverVerNG2 <- str_detect(AllIDG2, pattern="V") %>% sum()


OverExpSummaryG2<-c(OverIndNG2 , OverOblNG2, OverVerNG2)
OverExpSummaryG2


rbind(OverExpSummaryG1, OverExpSummaryG2) %>% data.frame() -> OverExpSummary
colnames(OverExpSummary)<-c("asocial","unrepaid","repaid")
rownames(OverExpSummary)<-c("G1","G2")
OverExpSummary
OverExpSummary/20
'Geneartion1'
'L,W,T'
  1. 'I4'
  2. 'I17'
  3. 'V6'
  4. 'V7'
  5. 'V12'
  6. 'V13'
  1. 'I4'
  2. 'I15'
  3. 'I17'
  4. 'O1'
  5. 'O3'
  6. 'V1'
  7. 'V2'
  8. 'V3'
  9. 'V6'
  10. 'V7'
  11. 'V11'
  12. 'V15'
  13. 'V18'
  14. 'V19'
'O15'
  1. 3
  2. 3
  3. 11
'Geneartion2'
'L,W,T'
  1. 'O1'
  2. 'O3'
  3. 'O5'
  4. 'O9'
  5. 'O11'
  6. 'O17'
  7. 'O20'
  8. 'V6'
  9. 'V7'
  10. 'V12'
  11. 'V13'
  12. 'V18'
  13. 'V19'
  14. 'V20'
  1. 'O1'
  2. 'O3'
  3. 'O6'
  4. 'O8'
  5. 'O10'
  6. 'O12'
  7. 'O17'
  8. 'O18'
  9. 'O19'
  10. 'O20'
  11. 'V1'
  12. 'V3'
  13. 'V5'
  14. 'V6'
  15. 'V7'
  16. 'V8'
  17. 'V10'
  18. 'V11'
  19. 'V12'
  20. 'V15'
  21. 'V16'
  22. 'V18'
  23. 'V19'
  24. 'V20'
  1. 'O15'
  2. 'V7'
  1. 0
  2. 14
  3. 15
A data.frame: 2 × 3
asocialunrepaidrepaid
<int><int><int>
G13 311
G201415
A data.frame: 2 × 3
asocialunrepaidrepaid
<dbl><dbl><dbl>
G10.150.150.55
G20.000.700.75
In [47]:
OverExpLength<-(df$Length > LengthOptimal)+0 
OverExpWidth<-(df$Width > WidthOptimal)+0 
OverExpThickness<-(df$Thickness < ThicknessOptimal)+0
In [48]:
df
A data.frame: 5000 × 20
IDChainIDGenerationExpConditionAgeGenderTrialChoiceLengthWidthThicknessFitnesserroredFitnessEarnedMoneyTimeStampNumIDOrderOverExpLengthOverExpWidthOverExpThickness
<chr><int><int><chr><int><int><int><int><int><int><int><int><int><dbl><dbl><int><dbl><dbl><dbl><dbl>
I111I201 1114 683364373 14.922.022012e+13116000
I111I201 2219 683394373 14.922.022012e+13116000
I111I201 3119 683394386 30.362.022012e+13116000
I111I201 4224 683421386 30.362.022012e+13116000
I111I201 5124 683421413 46.882.022012e+13116000
I111I201 6229 683446413 46.882.022012e+13116000
I111I201 7129 683446446 64.722.022012e+13116000
I111I201 8234 683467446 64.722.022012e+13116000
I111I201 9134 683467466 83.362.022012e+13116000
I111I20110234 678497466 83.362.022012e+13116000
I111I20111134 678497502103.442.022012e+13116000
I111I20112234 673525502103.442.022012e+13116000
I111I20113134 673525516124.082.022012e+13116000
I111I20114234 668551516124.082.022012e+13116000
I111I20115134 668551549146.042.022012e+13116000
I111I20116234 663574549146.042.022012e+13116000
I111I20117134 663574579169.202.022012e+13116000
I111I20118234 658596579169.202.022012e+13116000
I111I20119134 658596598193.122.022012e+13116000
I111I20120234 653615598193.122.022012e+13116000
I111I20121134 653615615217.722.022012e+13116000
I111I20122234 648632615217.722.022012e+13116000
I111I20123134 648632623242.642.022012e+13116000
I111I20124239 648651623242.642.022012e+13116000
I111I20125139 648651639268.202.022012e+13116000
I111I201262391148704639268.202.022012e+13116000
I111I201271391148704710296.602.022012e+13116000
I111I201281391148704716325.242.022012e+13116000
I111I201292391648750716325.242.022012e+13116000
I111I201301391648750745355.042.022012e+13116000
⋮⋮⋮⋮⋮⋮⋮⋮⋮⋮⋮⋮⋮⋮⋮⋮⋮⋮⋮⋮
V20202V222212704673833809 325.202.022021e+131008000
V20202V222221704673833840 358.802.022021e+131008000
V20202V222231704673833835 392.202.022021e+131008000
V20202V222242704173827835 392.202.022021e+131008000
V20202V222251704173827821 425.042.022021e+131008000
V20202V222262704373830821 425.042.022021e+131008000
V20202V222271704373830817 457.722.022021e+131008000
V20202V222281704373830820 490.522.022021e+131008000
V20202V222291704373830836 523.962.022021e+131008000
V20202V222301704373830831 557.202.022021e+131008000
V20202V222311704373830832 590.482.022021e+131008000
V20202V222321704373830829 623.642.022021e+131008000
V20202V222331704373830821 656.482.022021e+131008000
V20202V222341704373830834 689.842.022021e+131008000
V20202V222351704373830831 723.082.022021e+131008000
V20202V222361704373830837 756.562.022021e+131008000
V20202V222371704373830829 789.722.022021e+131008000
V20202V222381704373830824 822.682.022021e+131008000
V20202V222391704373830835 856.082.022021e+131008000
V20202V222401704373830829 889.242.022021e+131008000
V20202V222411704373830827 922.322.022021e+131008000
V20202V222421704373830828 955.442.022021e+131008000
V20202V222431704373830831 988.682.022021e+131008000
V20202V2224417043738308311021.922.022021e+131008000
V20202V2224517043738308301055.122.022021e+131008000
V20202V2224617043738308271088.202.022021e+131008000
V20202V2224717043738308261121.242.022021e+131008000
V20202V2224817043738308331154.562.022021e+131008000
V20202V2224917043738308331187.882.022021e+131008000
V20202V2225017043738308221220.762.022021e+131008000
In [49]:
df[(df$Length > LengthOptimal)|(df$Generation==1) ,]
A data.frame: 3331 × 20
IDChainIDGenerationExpConditionAgeGenderTrialChoiceLengthWidthThicknessFitnesserroredFitnessEarnedMoneyTimeStampNumIDOrderOverExpLengthOverExpWidthOverExpThickness
<chr><int><int><chr><int><int><int><int><int><int><int><int><int><dbl><dbl><int><dbl><dbl><dbl><dbl>
1I111I201 1114 683364373 14.922.022012e+13116000
2I111I201 2219 683394373 14.922.022012e+13116000
3I111I201 3119 683394386 30.362.022012e+13116000
4I111I201 4224 683421386 30.362.022012e+13116000
5I111I201 5124 683421413 46.882.022012e+13116000
6I111I201 6229 683446413 46.882.022012e+13116000
7I111I201 7129 683446446 64.722.022012e+13116000
8I111I201 8234 683467446 64.722.022012e+13116000
9I111I201 9134 683467466 83.362.022012e+13116000
10I111I20110234 678497466 83.362.022012e+13116000
11I111I20111134 678497502103.442.022012e+13116000
12I111I20112234 673525502103.442.022012e+13116000
13I111I20113134 673525516124.082.022012e+13116000
14I111I20114234 668551516124.082.022012e+13116000
15I111I20115134 668551549146.042.022012e+13116000
16I111I20116234 663574549146.042.022012e+13116000
17I111I20117134 663574579169.202.022012e+13116000
18I111I20118234 658596579169.202.022012e+13116000
19I111I20119134 658596598193.122.022012e+13116000
20I111I20120234 653615598193.122.022012e+13116000
21I111I20121134 653615615217.722.022012e+13116000
22I111I20122234 648632615217.722.022012e+13116000
23I111I20123134 648632623242.642.022012e+13116000
24I111I20124239 648651623242.642.022012e+13116000
25I111I20125139 648651639268.202.022012e+13116000
26I111I201262391148704639268.202.022012e+13116000
27I111I201271391148704710296.602.022012e+13116000
28I111I201281391148704716325.242.022012e+13116000
29I111I201292391648750716325.242.022012e+13116000
30I111I201301391648750745355.042.022012e+13116000
⋮⋮⋮⋮⋮⋮⋮⋮⋮⋮⋮⋮⋮⋮⋮⋮⋮⋮⋮⋮⋮
4928V20201V203282543183723704254.442.022021e+13 997000
4929V20201V203292543683742704254.442.022021e+13 997000
4930V20201V203301543683742743284.162.022021e+13 997000
4931V20201V203312544183755743284.162.022021e+13 997000
4932V20201V203321544183755757314.442.022021e+13 997000
4933V20201V203332544188722757314.442.022021e+13 997000
4934V20201V203341544188722724343.402.022021e+13 997000
4935V20201V203352544183755724343.402.022021e+13 997000
4936V20201V203362544178785724343.402.022021e+13 997000
4937V20201V203371544178785780374.602.022021e+13 997000
4938V20201V203382544173812780374.602.022021e+13 997000
4939V20201V203391544173812810407.002.022021e+13 997000
4940V20201V203402544168838810407.002.022021e+13 997000
4941V20201V203411544168838840440.602.022021e+13 997000
4942V20201V203422594168846840440.602.022021e+13 997000
4943V20201V203431594168846852474.682.022021e+13 997000
4944V20201V203442594668852852474.682.022021e+13 997000
4945V20201V203451594668852852508.762.022021e+13 997000
4946V20201V203462644668857852508.762.022021e+13 997000
4947V20201V203471644668857854542.922.022021e+13 997000
4948V20201V203482644168851854542.922.022021e+13 997000
4949V20201V203491644168851857577.202.022021e+13 997000
4950V20201V203501644168851855611.402.022021e+13 997000
4958V20202V222 82745173831832100.242.022021e+131008110
4959V20202V222 91745173831836133.682.022021e+131008110
4960V20202V222102745178803836133.682.022021e+131008110
4961V20202V222111745178803792165.362.022021e+131008110
4962V20202V222121745178803793197.082.022021e+131008110
4963V20202V222132745678796793197.082.022021e+131008110
4964V20202V222141745678796792228.762.022021e+131008110

Length¶

In [50]:
labeli <- as_labeller(c("I" = "Asocial",
                         "O" = "Unrepaid",
                         "V" = "Repaid",
                        "1"="First Generation","2"="Second Generation"))

options(repr.plot.width=10, repr.plot.height=10)
ggplot(df, aes(x=Trial,y=Length, group = as.factor(ID), color = as.factor(ChainID))) + 
geom_point(alpha =0.5)+  geom_line(alpha=0.6)+
geom_hline(yintercept = 70, size = 0.6, linetype = 1) +
ylim(0,100)+
theme_bw()+
guides(color=guide_legend(title="ID"))+theme(legend.position = "none")+
theme(text = element_text(size = 16))+
facet_grid(ExpCondition ~ Generation,labeller = labeli) -> Lplot
Lplot
In [51]:
labeli <- as_labeller(c("I" = "Asocial",
                         "O" = "Unrepaid",
                         "V" = "Repaid",
                        "1"="First Generation","2"="Second Generation"))

options(repr.plot.width=12, repr.plot.height=12)
ggplot(df, aes(x=Trial,y=Length, group = as.factor(ID), color = as.factor(OverExpLength))) +  
geom_point(alpha =0.5)+  geom_line(alpha=0.5)+
guides(color=guide_legend(title="Overexploration"))+
geom_hline(yintercept = 70, size = 0.6, linetype = 1) +
ylim(0,100)+
theme_bw()+
theme(text = element_text(size = 16))+
facet_grid(ExpCondition ~ Generation,labeller = labeli)

Width¶

In [52]:
options(repr.plot.width=10, repr.plot.height=10)
ggplot(df, aes(x=Trial,y=Width, group = as.factor(ID), color = as.factor(ChainID), alpha = 0.2)) + 
geom_point(alpha =0.5)+  geom_line(alpha=0.6)+
geom_hline(yintercept = 48, size = 0.6, linetype = 1) +
ylim(0,100)+
theme_bw()+
theme(text = element_text(size = 16))+
guides(color=guide_legend(title="ID"))+theme(legend.position = "none")+
facet_grid(ExpCondition ~ Generation,labeller = labeli) -> Wplot
Wplot
In [53]:
options(repr.plot.width=12, repr.plot.height=12)
ggplot(df, aes(x=Trial,y=Width, group = as.factor(ID), color = as.factor(OverExpWidth), alpha = 0.2)) +
geom_point(alpha =0.5)+  geom_line(alpha=0.5)+
guides(color=guide_legend(title="Overexploration"))+
geom_hline(yintercept = 48, size = 0.6, linetype = 1) +
ylim(0,100)+
theme_bw()+
theme(text = element_text(size = 16))+
facet_grid(ExpCondition ~ Generation,labeller = labeli)

Thickness¶

In [54]:
options(repr.plot.width=10, repr.plot.height=10)
ggplot(df, aes(x=Trial,y=Thickness, group = as.factor(ID), color = as.factor(ChainID))) +
geom_point(alpha =0.5)+  geom_line(alpha=0.6)+
geom_hline(yintercept = 11, size = 0.6, linetype = 1) +
ylim(0,100)+
theme_bw()+
theme(text = element_text(size = 16))+
guides(color=guide_legend(title="ID"))+theme(legend.position = "none")+
facet_grid(ExpCondition ~ Generation,labeller = labeli) -> Tplot
Tplot
In [55]:
options(repr.plot.width=12, repr.plot.height=12)
ggplot(df, aes(x=Trial,y=Thickness, group = as.factor(ID), color = as.factor(OverExpThickness), alpha = 0.2)) +  
geom_point(alpha =0.5)+  geom_line(alpha=0.5)+
guides(color=guide_legend(title="Overexploration"))+
geom_hline(yintercept = 11, size = 0.6, linetype = 1) +
ylim(0,100)+
theme_bw()+
theme(text = element_text(size = 16))+
facet_grid(ExpCondition ~ Generation,labeller = labeli)
In [56]:
options(repr.plot.width=12, repr.plot.height=12)
y_title <- expression("Cumulative payoff")
x_title <- expression("Trial")
labeli <- as_labeller(c("I" = "Asocial",
                         "O" = "Unrepaid",
                         "V" = "Repaid",
                        "1"="First Geneartion",
                        "2"="Second Generation"))

#options(repr.plot.width=6., repr.plot.height=6.5)
df %>%  ggplot(aes(x=Trial,y=as.numeric(EarnedMoney/2)))+
geom_line(aes(group =ChainID, color = as.factor(ChainID)), alpha = 0.3)+
geom_point(aes(group =ChainID, color = as.factor(ChainID)), alpha = 0.5)+  
facet_grid(ExpCondition ~ Generation, labeller=labeli ) +
                      theme_bw() +theme(legend.position = "none")+
stat_summary(fun="mean", geom="line", alpha = 1, size = 1.3) +
stat_summary(fun="mean", geom="point", alpha = 1, size = 1.6)+
ylab(y_title)+xlab(x_title)+theme(text = element_text(size = 16))+
stat_summary(fun = mean,
               fun.min = function(x) mean(x) - sd(x)/sqrt(length(x)), 
               fun.max = function(x) mean(x) + sd(x)/sqrt(length(x)), 
               alpha = 0.8,  geom = "linerange", size =0.5)+geom_hline(yintercept = 364, size = 0.4, linetype = 5)  -> CPayoffG
CPayoffG
In [57]:
library(gridExtra)
options(repr.plot.width=26, repr.plot.height=12)
grid.arrange(Lplot, Wplot, Tplot, nrow = 1) -> LWTg


LWTg
ggsave("Figures/LWTshift.pdf",LWTg, dpi = 220, device = "pdf", width = 26, height = 12)
Attaching package: ‘gridExtra’


The following object is masked from ‘package:dplyr’:

    combine


TableGrob (1 x 3) "arrange": 3 grobs
  z     cells    name           grob
1 1 (1-1,1-1) arrange gtable[layout]
2 2 (1-1,2-2) arrange gtable[layout]
3 3 (1-1,3-3) arrange gtable[layout]
In [58]:
library(gridExtra)
options(repr.plot.width=18, repr.plot.height=18)






layout <- rbind(c(1, 2),
                 c(3, 4))
grid.arrange(Lplot, Wplot, Tplot, CPayoffG, layout_matrix =layout) -> LWTPayoffgraph
ggsave("Figures/LWTshiftPayoff.pdf", LWTPayoffgraph, dpi = 220, device = "pdf", width = 18, height = 18)

Efficiency¶

Visualization in whole trials¶

In [59]:
y_title <- expression("Technological efficiency")
x_title <- expression("Trial")
labeli <- as_labeller(c("I" = "Asocial",
                         "O" = "Unrepaid",
                         "V" = "Repaid",
                        "1"="First Geneartion",
                        "2"="Second Generation"))

options(repr.plot.width=6., repr.plot.height=6.5)
df %>%  ggplot(aes(x=Trial,y=as.numeric(Fitness)))+
geom_line(aes(group =ChainID, color = as.factor(ChainID)), alpha = 0.3)+
geom_point(aes(group =ChainID, color = as.factor(ChainID)),size = 0.7, alpha = 0.5)+  
facet_grid(ExpCondition ~ Generation, labeller=labeli ) +
                      theme_bw() +theme(legend.position = "none")+
stat_summary(fun="mean", geom="line", alpha = 1, size = 0.5) +
stat_summary(fun="mean", geom="point", alpha = 1, size = 0.9)+
ylab(y_title)+xlab(x_title)+
stat_summary(fun = mean,
               fun.min = function(x) mean(x) - sd(x)/sqrt(length(x)), 
               fun.max = function(x) mean(x) + sd(x)/sqrt(length(x)), 
               alpha = 0.8,  geom = "linerange", size =0.5)
ggsave("MEfficienct.pdf", dpi = 220, device = "pdf", width = 6, height = 6.5)
ggsave("MEfficienct.png", dpi = 220, device = "png", width = 6, height = 6.5)

Mean Efficiency (pointless graph)¶

(Visualization)¶

In [60]:
options(repr.plot.width=6, repr.plot.height=3)
g <- ggplot(EfficiencyDf[EfficiencyDf$Generation ==1,], aes(x =as.factor(ExpCondition), y = Efficiency,fill =as.factor(ExpCondition))) +
  ggdist::stat_slab( aes(x =as.numeric(as.factor(ExpCondition))+0.1),
    alpha = 0.9,
    width = .24, 
    .width = c(0.00002, .92), 
  ) +
geom_jitter(size = 0.7,height=0, width =0.05, alpha = 0.7,aes(x = as.factor(ExpCondition), color =as.factor(ExpCondition))) +
coord_cartesian(xlim = c(1.0, NA), ylim=c(400,800))+theme_bw()+
scale_color_manual(values = CPalet, name = "Condition",labels = c("Asocial", "Unrepaid","Repaid"))+
scale_fill_manual(values = CPalet, name = "Condition",labels = c("Asocial", "Unrepaid","Repaid"))+
ylab(y_title )+xlab("Experimental Conition")+
scale_x_discrete("Condition", labels = c("I" = "Asocial","O" = "Nonrepaid", "V" = "Repaid"))+
stat_summary(fun= mean,  geom="bar", alpha = 1, width = 0.2, color = "black",aes(x = as.numeric(as.factor(ExpCondition))-0.2)) +
stat_summary(fun.min = function(x) mean(x) -sd(x)/sqrt(length(x)), 
               fun.max = function(x) mean(x) + sd(x)/sqrt(length(x)), 
               geom = "errorbar", width =0.05, aes(x = as.numeric(as.factor(ExpCondition))-0.2))


g
In [61]:
options(repr.plot.width=9, repr.plot.height=3)
g <- ggplot(EfficiencyDf, aes(x =as.factor(ExpCondition), y = Efficiency,fill =as.factor(ExpCondition))) +
  ggdist::stat_slab( aes(x =as.numeric(as.factor(ExpCondition))+0.1),
    alpha = 0.9,
    width = .24, 
    .width = c(0.00002, .92), 
  ) +
geom_jitter(size = 0.7,height=0, width =0.05, alpha = 0.7,aes(x = as.factor(ExpCondition), color =as.factor(ExpCondition))) +
coord_cartesian(xlim = c(1.0, NA))+theme_bw()+
scale_color_manual(values = CPalet, name = "Condition",labels = c("Asocial", "Unrepaid","Repaid"))+
scale_fill_manual(values = CPalet, name = "Condition",labels = c("Asocial", "Unrepaid","Repaid"))+
ylab(y_title )+xlab("Experimental Conition")+
scale_x_discrete("Condition", labels = c("I" = "Asocial","O" = "Unrepaid", "V" = "Repaid"))+
stat_summary(fun= mean,  geom="bar", alpha = 1, width = 0.2, color = "black",aes(x = as.numeric(as.factor(ExpCondition))-0.2)) +
stat_summary(fun.min = function(x) mean(x) -sd(x)/sqrt(length(x)), 
               fun.max = function(x) mean(x) + sd(x)/sqrt(length(x)), 
               geom = "errorbar", width =0.05, aes(x = as.numeric(as.factor(ExpCondition))-0.2))+
                facet_grid(.~Generation, labeller = labeli )


g
In [62]:
y_title <- expression(paste("Exploration trials (", italic(tau), ")"))
#taulabel<-"a"

taulabel<- expression(italic(tau)*"*")

options(repr.plot.width=6, repr.plot.height=6)

suppressMessages(
 suppressWarnings(
g <- ggplot(ExpDf, aes(x =as.factor(ExpCondition), y = Exploration,fill =as.factor(ExpCondition))) +
  ggdist::stat_slab( aes(x =as.numeric(as.factor(ExpCondition))+0.1),
    alpha = 0.9,
    width = .24, 
    .width = c(0.00002, .92), 
  ) + 
geom_jitter(size = 0.7,height=0, width =0.05, alpha = 0.7,aes(x = as.factor(ExpCondition), color =as.factor(ExpCondition))) +
coord_cartesian(xlim = c(1.0, NA))+theme_bw()+
scale_color_manual(values = CPalet, name = "Condition",labels = c("Asocial", "Unrepaid","Repaid"))+
scale_fill_manual(values = CPalet, name = "Condition",labels = c("Asocial", "Unrepaid","Repaid"))+
ylab(y_title )+xlab("Experimental Conition")+
scale_x_discrete("Condition", labels = c("I" = "Asocial","O" = "Unrepaid", "V" = "Repaid"))+
#stat_summary(fun= mean,  geom="bar", alpha = 1, width = 0.2, color = "black",aes(x = as.numeric(as.factor(ExpCondition))-0.2)) +
geom_boxplot(alpha=0.7, width =0.2, aes(x = as.numeric(as.factor(ExpCondition))-0.2))+
# geom_segment(aes(x=0.6,xend=1.22,y=12,yend=12),linetype=2, color = "grey39", size = 0.4)+
# geom_segment(aes(x=1.6,xend=2.22,y=12,yend=12),linetype=2, color = "grey39", size = 0.4)+
# geom_segment(aes(x=2.6,xend=3.22,y=22,yend=22),linetype=2, color = "grey39", size = 0.4)+
     stat_summary(fun= mean,  geom="point", size = 3, shape = 18 , alpha = 1, width = 0.2, color = "black",aes(x = as.numeric(as.factor(ExpCondition))-0.2)) +
stat_summary(fun.min = function(x) mean(x) -sd(x)/sqrt(length(x)), 
              fun.max = function(x) mean(x) + sd(x)/sqrt(length(x)), 
              geom = "errorbar", width =0.05, aes(x = as.numeric(as.factor(ExpCondition))-0.2))+
                facet_grid(Generation~., labeller = labeli )
     #+
#annotate("text",x=1.3,y=0.01+12,label=taulabel) +
#annotate("text",x=2.3,y=0.01+12,label=taulabel) +
#annotate("text",x=3.3,y=0.01+22,label=taulabel) 
 
 ))

suppressMessages(
 suppressWarnings(g)
    )

FInal trial comparison¶

In [63]:
OblOffline<-df[(df$Generation == 1)&(df$ExpCondition == "O"), ]$Fitness 
VerOffline<-df[(df$Generation == 1)&(df$ExpCondition == "V"), ]$Fitness 
IndOffline<-df[(df$Generation == 1)&(df$ExpCondition == "I"), ]$Fitness
In [64]:
OblOfflineF<-df[(df$Generation == 1)&(df$ExpCondition == "O")&(df$Trial == 50), ]$Fitness 
VerOfflineF<-df[(df$Generation == 1)&(df$ExpCondition == "V")&(df$Trial == 50), ]$Fitness 
IndOfflineF<-df[(df$Generation == 1)&(df$ExpCondition == "I")&(df$Trial == 50), ]$Fitness 


OblOfflineF2<-df[(df$Generation == 2)&(df$ExpCondition == "O")&(df$Trial == 50), ]$Fitness 
VerOfflineF2<-df[(df$Generation == 2)&(df$ExpCondition == "V")&(df$Trial == 50), ]$Fitness
In [65]:
"Ind"
psych::describe(IndOfflineF) %>% round(.,2)
"Obl"
psych::describe(OblOfflineF)%>% round(.,2)
"Ver"
psych::describe(VerOfflineF)%>% round(.,2)
'Ind'
A psych: 1 × 13
varsnmeansdmediantrimmedmadminmaxrangeskewkurtosisse
<dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl>
X1120820.2569.02830824.4457.82667940273-0.51-0.4215.43
'Obl'
A psych: 1 × 13
varsnmeansdmediantrimmedmadminmaxrangeskewkurtosisse
<dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl>
X1120789.9119.59800802.38138.62461940479-0.890.4826.74
'Ver'
A psych: 1 × 13
varsnmeansdmediantrimmedmadminmaxrangeskewkurtosisse
<dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl>
X1120838.7103.16845.5847.75111.94627975348-0.53-0.7523.07
In [66]:
options(repr.plot.width=9, repr.plot.height=4)
g <- ggplot(df[df$Trial == 50,], aes(x =as.factor(ExpCondition), y =Fitness,fill =as.factor(ExpCondition))) +
  ggdist::stat_slab( aes(x =as.numeric(as.factor(ExpCondition))+0.1),
    alpha = 0.9,
    width = .24, 
    .width = c(0.00002, .92), 
  ) +
geom_jitter(size = 0.7,height=0, width =0.05, alpha = 0.7,aes(x = as.factor(ExpCondition), color =as.factor(ExpCondition))) +
coord_cartesian(xlim = c(1.0, NA),ylim=c(400,1000))+theme_bw()+
scale_color_manual(values = CPalet, name = "Condition",labels = c("Asocial", "Unrepaid","Repaid"))+
scale_fill_manual(values = CPalet, name = "Condition",labels = c("Asocial", "Unrepaid","Repaid"))+
ylab(y_title )+xlab("Experimental Conition")+
scale_x_discrete("Condition", labels = c("I" = "Asocial","O" = "Nonrepaid", "V" = "Repaid"))+
stat_summary(fun= mean,  geom="bar", alpha = 1, width = 0.2, color = "black",aes(x = as.numeric(as.factor(ExpCondition))-0.2)) +
stat_summary(fun.min = function(x) mean(x) -sd(x)/sqrt(length(x)), 
               fun.max = function(x) mean(x) + sd(x)/sqrt(length(x)), 
               geom = "errorbar", width =0.05, aes(x = as.numeric(as.factor(ExpCondition))-0.2))+
                facet_grid(.~Generation,labeller = labeli)


g
In [67]:
options(repr.plot.width=9, repr.plot.height=4)
g <- ggplot(df[df$Trial == 50,], aes(x =as.factor(ExpCondition), y =Fitness,fill =as.factor(ExpCondition))) +
  ggdist::stat_slab( aes(x =as.numeric(as.factor(ExpCondition))+0.1),
    alpha = 0.9,
    width = .24, 
    .width = c(0.00002, .92), 
  ) +
geom_jitter(size = 0.7,height=0, width =0.05, alpha = 0.7,aes(x = as.factor(ExpCondition), color =as.factor(ExpCondition))) +
coord_cartesian(xlim = c(1.0, NA),ylim=c(0,1000))+theme_bw()+
scale_color_manual(values = CPalet, name = "Condition",labels = c("Asocial", "Unrepaid","Repaid"))+
scale_fill_manual(values = CPalet, name = "Condition",labels = c("Asocial", "Unnrepaid","Repaid"))+
ylab(y_title )+xlab("Experimental Conition")+
scale_x_discrete("Condition", labels = c("I" = "Asocial","O" = "Nonrepaid", "V" = "Repaid"))+
stat_summary(fun= mean,  geom="bar", alpha = 1, width = 0.2, color = "black",aes(x = as.numeric(as.factor(ExpCondition))-0.2)) +
stat_summary(fun.min = function(x) mean(x) -sd(x)/sqrt(length(x)), 
               fun.max = function(x) mean(x) + sd(x)/sqrt(length(x)), 
               geom = "errorbar", width =0.05, aes(x = as.numeric(as.factor(ExpCondition))-0.2))+
                facet_grid(.~Generation,labeller = labeli)


g

Repaid vs. Asocial¶

In [68]:
library(exactRankTests)
 Package ‘exactRankTests’ is no longer under development.
 Please consider using package ‘coin’ instead.


In [69]:
t.test(VerOfflineF, IndOfflineF)
t.test(log(VerOfflineF), log(IndOfflineF))
wilcox.exact(VerOfflineF, IndOfflineF,paired=F)
effsize::cohen.d(VerOfflineF, IndOfflineF)
	Welch Two Sample t-test

data:  VerOfflineF and IndOfflineF
t = 0.66478, df = 33.171, p-value = 0.5108
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -38.00408  74.90408
sample estimates:
mean of x mean of y 
   838.70    820.25 
	Welch Two Sample t-test

data:  log(VerOfflineF) and log(IndOfflineF)
t = 0.51941, df = 33.233, p-value = 0.6069
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -0.05271388  0.08886949
sample estimates:
mean of x mean of y 
 6.724187  6.706109 
	Exact Wilcoxon rank sum test

data:  VerOfflineF and IndOfflineF
W = 233.5, p-value = 0.3724
alternative hypothesis: true mu is not equal to 0
Cohen's d

d estimate: 0.2102214 (small)
95 percent confidence interval:
     lower      upper 
-0.4317140  0.8521568 
In [70]:
sd(VerOfflineF)
sd(IndOfflineF)
103.157569816889
69.0201152982917

Nonrepaid vs. Asocial¶

In [71]:
library(exactRankTests)

t.test(OblOfflineF, IndOfflineF)
t.test(log(OblOfflineF), log(IndOfflineF))
wilcox.exact(OblOfflineF, IndOfflineF,paired=F)
effsize::cohen.d(OblOfflineF, IndOfflineF)
	Welch Two Sample t-test

data:  OblOfflineF and IndOfflineF
t = -0.98299, df = 30.393, p-value = 0.3334
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -93.37118  32.67118
sample estimates:
mean of x mean of y 
   789.90    820.25 
	Welch Two Sample t-test

data:  log(OblOfflineF) and log(IndOfflineF)
t = -1.0998, df = 28.342, p-value = 0.2807
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -0.13381614  0.04028977
sample estimates:
mean of x mean of y 
 6.659346  6.706109 
	Exact Wilcoxon rank sum test

data:  OblOfflineF and IndOfflineF
W = 176.5, p-value = 0.5334
alternative hypothesis: true mu is not equal to 0
Cohen's d

d estimate: -0.3108495 (small)
95 percent confidence interval:
     lower      upper 
-0.9548737  0.3331747 
In [72]:
sd(OblOfflineF)
119.589605251504

Second Generation¶

In [73]:
t.test(VerOfflineF2, OblOfflineF2)
t.test(log(VerOfflineF2), log(OblOfflineF2))
wilcox.exact(VerOfflineF2, OblOfflineF2,paired=F)
effsize::cohen.d(VerOfflineF2, OblOfflineF2)
	Welch Two Sample t-test

data:  VerOfflineF2 and OblOfflineF2
t = 0.76869, df = 37.976, p-value = 0.4468
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -30.3853  67.5853
sample estimates:
mean of x mean of y 
   897.85    879.25 
	Welch Two Sample t-test

data:  log(VerOfflineF2) and log(OblOfflineF2)
t = 0.75387, df = 37.953, p-value = 0.4556
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -0.03576342  0.07820096
sample estimates:
mean of x mean of y 
 6.796465  6.775246 
	Exact Wilcoxon rank sum test

data:  VerOfflineF2 and OblOfflineF2
W = 232, p-value = 0.3945
alternative hypothesis: true mu is not equal to 0
Cohen's d

d estimate: 0.2430811 (small)
95 percent confidence interval:
     lower      upper 
-0.3994484  0.8856105 

(Cumulative Cultural Evolution)¶

In [74]:
t.test(OblOfflineF2-OblOfflineF)
#cohen.d(OblOfflineF2-OblOfflineF)

OblCCE<-OblOfflineF2-OblOfflineF
	One Sample t-test

data:  OblOfflineF2 - OblOfflineF
t = 4.3618, df = 19, p-value = 0.0003357
alternative hypothesis: true mean is not equal to 0
95 percent confidence interval:
  46.47505 132.22495
sample estimates:
mean of x 
    89.35 
In [75]:
t.test(VerOfflineF2-VerOfflineF)
#cohen.d(VerOfflineF2-VerOfflineF)


VerCCE<-VerOfflineF2-VerOfflineF
	One Sample t-test

data:  VerOfflineF2 - VerOfflineF
t = 3.4751, df = 19, p-value = 0.002535
alternative hypothesis: true mean is not equal to 0
95 percent confidence interval:
 23.52447 94.77553
sample estimates:
mean of x 
    59.15 
In [76]:
t.test(VerCCE,OblCCE)
	Welch Two Sample t-test

data:  VerCCE and OblCCE
t = -1.1339, df = 36.767, p-value = 0.2642
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -84.17601  23.77601
sample estimates:
mean of x mean of y 
    59.15     89.35 


Questionnaire¶

In [77]:
datad<-read.csv("PostQuestionData.csv")
In [78]:
colnames(datad)
  1. 'Header'
  2. 'ID'
  3. 'day'
  4. 'time'
  5. 'session'
  6. 'generation'
  7. 'condition'
  8. 'PC'
  9. 'Str_turn'
  10. 'Str_switch'
  11. 'ignore_cost'
  12. 'overspent'
  13. 'more_spent'
  14. 'maxim'
  15. 'Generation'
  16. 'FutureThink'
  17. 'Ancestor'
  18. 'Return'
  19. 'SV1'
  20. 'SV2'
  21. 'SV3'
  22. 'SV4'
  23. 'SV5'
  24. 'SV6'
  25. 'SV7'
  26. 'SV8'
  27. 'SV9'

Strategy Proportion¶

In [79]:
options(warn = -1)
datad %>% group_by(., condition, generation) %>% 
dplyr::summarize(, n = n(), Str_turn= 2-mean(Str_turn),  Str_switch= 2-mean(Str_switch))


datad %>% group_by(., condition, generation) %>% 
dplyr::summarize(, n = n(), Str_turn= (2-mean(Str_turn))*20,  Str_switch= (2-mean(Str_switch))*20)
`summarise()` has grouped output by 'condition'. You can override using the `.groups` argument.
A grouped_df: 5 × 5
conditiongenerationnStr_turnStr_switch
<chr><int><int><dbl><dbl>
I1200.850.80
O1200.850.65
O2200.751.00
V1200.800.40
V2200.650.95
`summarise()` has grouped output by 'condition'. You can override using the `.groups` argument.
A grouped_df: 5 × 5
conditiongenerationnStr_turnStr_switch
<chr><int><int><dbl><dbl>
I1201716
O1201713
O2201520
V12016 8
V2201319

(Other scales)¶

In [80]:
datad %>% group_by(., condition, generation) %>% 
dplyr::summarize(, n = n(), Mingore_cost=round(mean (ignore_cost, na.rm = TRUE),2),
                SDingore_cost=round(sd(ignore_cost, na.rm = TRUE),2),
                 Moverspent=mean(overspent), 
                 SDoverspent=sd(overspent)%>%round(2), 
                 Mmorespent=mean(more_spent), 
                 SDmorespent=sd(more_spent)%>%round(2), 
                 Mmaximize=mean(maxim), 
                 SDmaximize=sd(maxim)%>%round(2))
                 


datad %>% group_by(., condition, generation) %>% 
dplyr::summarize(, n = n(), 
                 MFutureThink=mean(FutureThink),
                 SFutureThink=sd(FutureThink)%>%round(2), 
                 MAncestor=mean(Ancestor),
                 SAncestor=sd(Ancestor)%>%round(2),
                 MReturn=mean(Return),
                 SReturn=sd(Return)%>%round(2))
`summarise()` has grouped output by 'condition'. You can override using the `.groups` argument.
A grouped_df: 5 × 11
conditiongenerationnMingore_costSDingore_costMoverspentSDoverspentMmorespentSDmorespentMmaximizeSDmaximize
<chr><int><int><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl>
I1203.101.943.151.735.051.362.601.50
O1203.841.684.401.904.501.763.301.56
O2203.851.664.901.925.451.571.801.15
V1202.601.604.502.044.502.012.151.50
V2204.202.074.852.165.751.212.551.43
`summarise()` has grouped output by 'condition'. You can override using the `.groups` argument.
A grouped_df: 5 × 9
conditiongenerationnMFutureThinkSFutureThinkMAncestorSAncestorMReturnSReturn
<chr><int><int><dbl><dbl><dbl><dbl><dbl><dbl>
I120 NA NA NA NA NA NA
O1204.51.61 NA NA NA NA
O220 NA NA2.751.774.11.55
V1202.81.94 NA NA NA NA
V220 NA NA2.201.322.31.53

SVO¶

Coding SVO¶

In [81]:
PROSOC_KEY<-c(3,2,1,3,2,1,1,3,2)
PROSELF_KEY<-c(2,1,3,2,1,3,2,1,3)
COMP_KEY    <-c(1,3,2,1,3,2,3,2,1)
In [82]:
SVO<-datad[,(dim(datad)[2]-8):dim(datad)[2]]
PSocScore<-apply(SVO==matrix(PROSOC_KEY,dim(SVO)[1],dim(SVO)[2],T) ,1, sum)
PSelfScore<-apply(SVO==matrix(PROSELF_KEY,dim(SVO)[1],dim(SVO)[2],T) ,1, sum)
CompScore<-apply(SVO==matrix(COMP_KEY,dim(SVO)[1],dim(SVO)[2],T) ,1, sum)
In [83]:
datadp<-mutate(datad, PSocScore,PSelfScore,CompScore)
In [84]:
#mean(datadp[(datadp$condition=="I")&(datadp$generation==1),]$PSocScore)
#mean(datadp[(datadp$condition=="O")&(datadp$generation==1),]$PSocScore)
#mean(datadp[(datadp$condition=="V")&(datadp$generation==1),]$PSocScore)
#mean(datadp[(datadp$condition=="O")&(datadp$generation==2),]$PSocScore)
#mean(datadp[(datadp$condition=="V")&(datadp$generation==2),]$PSocScore)

SVO Categorization¶

In [85]:
SVO_cat<-numeric(dim(datad)[1])
SVO_cat[PSocScore > 5.9]<-"C"
SVO_cat[PSocScore < 5.9]<-"N"
SVO_cat[9-PSocScore > 5.9]<-"D"
#SVO_cat

IfSocial<-numeric(dim(datad)[1])
IfSocial[PSocScore > 5.9]<-1

datadp<-mutate(datadp, SVO_cat,IfSocial)

SVO summary¶

In [86]:
datadp %>% group_by(., condition, generation) %>% 
dplyr::summarize(, n = n(), psoc_m = mean(PSocScore), psoc_sd = round(sd(PSocScore), 2),
          pself_m = mean(PSelfScore), pself_sd = round(sd(PSelfScore),2), 
          comp_m = mean(CompScore), comp_sd = round(sd(CompScore),2)) -> table_svo

table_svo
`summarise()` has grouped output by 'condition'. You can override using the `.groups` argument.
A grouped_df: 5 × 9
conditiongenerationnpsoc_mpsoc_sdpself_mpself_sdcomp_mcomp_sd
<chr><int><int><dbl><dbl><dbl><dbl><dbl><dbl>
I1204.853.624.153.620.000.00
O1205.004.343.954.290.050.22
O2204.753.954.203.930.000.00
V1204.554.074.404.070.050.22
V2204.254.274.704.220.050.22
In [87]:
#latex(table_svo, file = "table_svo_dexc.tex")

By Three Category C:Prosocial, D: Defector (Proself+Competitor), N:non-classified¶

In [88]:
(table(datadp[datadp$generation ==1,]$condition, datadp[datadp$generation ==1,]$SVO_cat)) ->G1SVO
(G1SVO)
(G1SVO)/20
   
     C  D  N
  I 10  9  1
  O 11  8  1
  V  9  9  2
   
       C    D    N
  I 0.50 0.45 0.05
  O 0.55 0.40 0.05
  V 0.45 0.45 0.10
In [89]:
(table(datadp[datadp$generation ==2,]$condition, datadp[datadp$generation ==2,]$SVO_cat)) ->G2SVO
(G2SVO)
(G2SVO)/20
   
     C  D  N
  O 10 10  0
  V  9 10  1
   
       C    D    N
  O 0.50 0.50 0.00
  V 0.45 0.50 0.05

Whether prosicial (1) or not (0)¶

In [90]:
(table(datadp[datadp$generation ==1,]$condition, datadp[datadp$generation ==1,]$IfSocial))
   
     0  1
  I 10 10
  O  9 11
  V 11  9
In [91]:
(table(datadp[datadp$generation ==1,]$condition, datadp[datadp$generation ==1,]$IfSocial)) ->G1IfSocial
G1IfSocial
G1IfSocial/20
   
     0  1
  I 10 10
  O  9 11
  V 11  9
   
       0    1
  I 0.50 0.50
  O 0.45 0.55
  V 0.55 0.45

SVO + LM/GLM¶

Data Merge¶

In [92]:
ExpDfSVO<-mutate(ExpDf, SVO_cat, IfSocial,PSocScore)
filter(ExpDfSVO, Generation == 1) -> ExpDfSVOG1
In [93]:
head(ExpDfSVO)
A data.frame: 6 × 9
IDExplorationGenerationExpConditionSessionIDGenderSVO_catIfSocialPSocScore
<int><dbl><int><chr><int><int><chr><dbl><int>
11181I11C16
22171I23D01
33211I33D00
44221I43C18
55191I52C18
66241I62C19

Gaussian¶

SVO as categorical¶

In [94]:
Gaus_cat<-lm(data = ExpDfSVOG1, Exploration~ExpCondition+IfSocial)
summary(Gaus_cat)
AIC(Gaus_cat)
Call:
lm(formula = Exploration ~ ExpCondition + IfSocial, data = ExpDfSVOG1)

Residuals:
     Min       1Q   Median       3Q      Max 
-12.3287  -2.8776  -0.3287   3.8656  12.1780 

Coefficients:
              Estimate Std. Error t value Pr(>|t|)    
(Intercept)    20.3466     1.3821  14.721   <2e-16 ***
ExpConditionO  -0.6253     1.6927  -0.369   0.7132    
ExpConditionV   4.4753     1.6927   2.644   0.0106 *  
IfSocial       -0.4933     1.3856  -0.356   0.7232    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 5.348 on 56 degrees of freedom
Multiple R-squared:  0.1657,	Adjusted R-squared:  0.1211 
F-statistic: 3.709 on 3 and 56 DF,  p-value: 0.01666
377.349603716867
In [95]:
apa.reg.table(Gaus_cat)

Regression results using Exploration as the criterion
 

     Predictor       b       b_95%_CI sr2  sr2_95%_CI             Fit
   (Intercept) 20.35** [17.58, 23.12]                                
 ExpConditionO   -0.63  [-4.02, 2.77] .00 [-.02, .02]                
 ExpConditionV   4.48*   [1.08, 7.87] .10 [-.04, .25]                
      IfSocial   -0.49  [-3.27, 2.28] .00 [-.02, .02]                
                                                           R2 = .166*
                                                      95% CI[.01,.31]
                                                                     

Note. A significant b-weight indicates the semi-partial correlation is also significant.
b represents unstandardized regression weights. 
sr2 represents the semi-partial correlation squared.
Square brackets are used to enclose the lower and upper limits of a confidence interval.
* indicates p < .05. ** indicates p < .01.
 

$Y_i = \beta_0 + \beta_1X_{unrepaid} + \beta_2X_{repaid} + \beta_3X_{prosicail} + \varepsilon$

Exploration is scaled¶
In [96]:
Gaus_cat_scale<-lm(data = ExpDfSVOG1, scale(Exploration)~ExpCondition+IfSocial)
summary(Gaus_cat_scale)
AIC(Gaus_cat_scale)
Call:
lm(formula = scale(Exploration) ~ ExpCondition + IfSocial, data = ExpDfSVOG1)

Residuals:
     Min       1Q   Median       3Q      Max 
-2.16108 -0.50442 -0.05762  0.67761  2.13467 

Coefficients:
              Estimate Std. Error t value Pr(>|t|)  
(Intercept)   -0.18172    0.24227  -0.750   0.4564  
ExpConditionO -0.10961    0.29672  -0.369   0.7132  
ExpConditionV  0.78448    0.29672   2.644   0.0106 *
IfSocial      -0.08647    0.24288  -0.356   0.7232  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.9375 on 56 degrees of freedom
Multiple R-squared:  0.1657,	Adjusted R-squared:  0.1211 
F-statistic: 3.709 on 3 and 56 DF,  p-value: 0.01666
168.391293556744
In [97]:
options(digits=2)
summary(Gaus_cat_scale)$coefficients
A matrix: 4 × 4 of type dbl
EstimateStd. Errort valuePr(>|t|)
(Intercept)-0.1820.24-0.750.456
ExpConditionO-0.1100.30-0.370.713
ExpConditionV 0.7840.30 2.640.011
IfSocial-0.0860.24-0.360.723
In [98]:
apa.reg.table(Gaus_cat_scale)

Regression results using scale(Exploration) as the criterion
 

     Predictor     b      b_95%_CI sr2  sr2_95%_CI             Fit
   (Intercept) -0.18 [-0.67, 0.30]                                
 ExpConditionO -0.11 [-0.70, 0.48] .00 [-.02, .02]                
 ExpConditionV 0.78*  [0.19, 1.38] .10 [-.04, .25]                
      IfSocial -0.09 [-0.57, 0.40] .00 [-.02, .02]                
                                                        R2 = .166*
                                                   95% CI[.01,.31]
                                                                  

Note. A significant b-weight indicates the semi-partial correlation is also significant.
b represents unstandardized regression weights. 
sr2 represents the semi-partial correlation squared.
Square brackets are used to enclose the lower and upper limits of a confidence interval.
* indicates p < .05. ** indicates p < .01.
 

SVO as contnious¶

In [99]:
Gaus_cont<-lm(data = ExpDfSVOG1, Exploration~ExpCondition+PSocScore)
summary(Gaus_cont)
AIC(Gaus_cont)

Gaus_cont_scale<-lm(data = ExpDfSVOG1, scale(Exploration)~ExpCondition+scale(PSocScore))
summary(Gaus_cont_scale)
AIC(Gaus_cont_scale)
Call:
lm(formula = Exploration ~ ExpCondition + PSocScore, data = ExpDfSVOG1)

Residuals:
    Min      1Q  Median      3Q     Max 
-11.845  -3.325  -0.011   3.801  11.661 

Coefficients:
              Estimate Std. Error t value Pr(>|t|)    
(Intercept)     20.905      1.480   14.13   <2e-16 ***
ExpConditionO   -0.608      1.681   -0.36    0.719    
ExpConditionV    4.434      1.682    2.64    0.011 *  
PSocScore       -0.166      0.182   -0.91    0.365    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 5.3 on 56 degrees of freedom
Multiple R-squared:  0.176,	Adjusted R-squared:  0.132 
F-statistic: 3.99 on 3 and 56 DF,  p-value: 0.012
376.597697562512
Call:
lm(formula = scale(Exploration) ~ ExpCondition + scale(PSocScore), 
    data = ExpDfSVOG1)

Residuals:
    Min      1Q  Median      3Q     Max 
-2.0762 -0.5829 -0.0019  0.6663  2.0441 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)  
(Intercept)        -0.223      0.208   -1.07    0.288  
ExpConditionO      -0.107      0.295   -0.36    0.719  
ExpConditionV       0.777      0.295    2.64    0.011 *
scale(PSocScore)   -0.111      0.122   -0.91    0.365  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.93 on 56 degrees of freedom
Multiple R-squared:  0.176,	Adjusted R-squared:  0.132 
F-statistic: 3.99 on 3 and 56 DF,  p-value: 0.012
167.63938740239
In [100]:
options(digits=2)
summary(Gaus_cont_scale)$coefficients
A matrix: 4 × 4 of type dbl
EstimateStd. Errort valuePr(>|t|)
(Intercept)-0.220.21-1.070.288
ExpConditionO-0.110.29-0.360.719
ExpConditionV 0.780.29 2.640.011
scale(PSocScore)-0.110.12-0.910.365
In [101]:
apa.reg.table(Gaus_cont_scale)

Regression results using scale(Exploration) as the criterion
 

        Predictor     b      b_95%_CI sr2  sr2_95%_CI             Fit
      (Intercept) -0.22 [-0.64, 0.19]                                
    ExpConditionO -0.11 [-0.70, 0.48] .00 [-.02, .02]                
    ExpConditionV 0.78*  [0.19, 1.37] .10 [-.04, .24]                
 scale(PSocScore) -0.11 [-0.35, 0.13] .01 [-.04, .06]                
                                                           R2 = .176*
                                                      95% CI[.01,.32]
                                                                     

Note. A significant b-weight indicates the semi-partial correlation is also significant.
b represents unstandardized regression weights. 
sr2 represents the semi-partial correlation squared.
Square brackets are used to enclose the lower and upper limits of a confidence interval.
* indicates p < .05. ** indicates p < .01.
 

(Poisson)¶

In [102]:
Pois_additive<-glm(data = ExpDfSVOG1, Exploration~ExpCondition+IfSocial, family = poisson(link="identity"))
Pois_additive_log<-glm(data = ExpDfSVOG1, Exploration~ExpCondition+IfSocial, family = poisson(link="log"))
summary(Pois_additive)

summary(Pois_additive_log)


#apa.reg.table(Pois_additive)
Call:
glm(formula = Exploration ~ ExpCondition + IfSocial, family = poisson(link = "identity"), 
    data = ExpDfSVOG1)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-2.9173  -0.6437  -0.0827   0.8330   2.2941  

Coefficients:
              Estimate Std. Error z value Pr(>|z|)    
(Intercept)     20.275      1.169   17.35   <2e-16 ***
ExpConditionO   -0.639      1.408   -0.45   0.6498    
ExpConditionV    4.467      1.496    2.99   0.0028 ** 
IfSocial        -0.335      1.192   -0.28   0.7788    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for poisson family taken to be 1)

    Null deviance: 91.645  on 59  degrees of freedom
Residual deviance: 77.163  on 56  degrees of freedom
AIC: 377.4

Number of Fisher Scoring iterations: 5
Call:
glm(formula = Exploration ~ ExpCondition + IfSocial, family = poisson(link = "log"), 
    data = ExpDfSVOG1)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-2.9066  -0.6570  -0.0586   0.8465   2.2697  

Coefficients:
              Estimate Std. Error z value Pr(>|z|)    
(Intercept)     3.0122     0.0570   52.80   <2e-16 ***
ExpConditionO  -0.0317     0.0712   -0.45   0.6559    
ExpConditionV   0.2009     0.0673    2.99   0.0028 ** 
IfSocial       -0.0231     0.0560   -0.41   0.6805    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for poisson family taken to be 1)

    Null deviance: 91.645  on 59  degrees of freedom
Residual deviance: 77.071  on 56  degrees of freedom
AIC: 377.3

Number of Fisher Scoring iterations: 4

gression results using Exploration as the criterion

 Predictor       b       b_95%_CI sr2  sr2_95%_CI           Fit

(Intercept) 20.35** [17.58, 23.12]
ExpConditionO -0.63 [-4.02, 2.77] .00 [-.02, .02]
ExpConditionV 4.48* [1.08, 7.87] .10 [-.04, .25]
IfSocial -0.49 [-3.27, 2.28] .00 [-.02, .02]
R2 = .166* 95% CI[NA,NA]

Note. A significant b-weight indicates the semi-partial correlation is also significant. b represents unstandardized regression weights. sr2 represents the semi-partial correlation squared. Square brackets are used to enclose the lower and upper limits of a confidence interval.

  • indicates p < .05. ** indicates p < .01.

Binomial¶

SVO as categorical¶

In [ ]:

In [103]:
options(digits=3)
BInomial_cat<-glm(data = ExpDfSVOG1,cbind(Exploration, 50-Exploration)~ExpCondition+IfSocial, family =binomial)
In [104]:
summary(BInomial_cat)
Call:
glm(formula = cbind(Exploration, 50 - Exploration) ~ ExpCondition + 
    IfSocial, family = binomial, data = ExpDfSVOG1)

Deviance Residuals: 
   Min      1Q  Median      3Q     Max  
-3.582  -0.838  -0.091   1.110   3.513  

Coefficients:
              Estimate Std. Error z value Pr(>|z|)    
(Intercept)    -0.3769     0.0744   -5.07  4.0e-07 ***
ExpConditionO  -0.0524     0.0916   -0.57     0.57    
ExpConditionV   0.3631     0.0904    4.02  5.9e-05 ***
IfSocial       -0.0407     0.0744   -0.55     0.58    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 161.35  on 59  degrees of freedom
Residual deviance: 135.44  on 56  degrees of freedom
AIC: 401.1

Number of Fisher Scoring iterations: 4
In [105]:
options(digits=1)
summary(BInomial_cat)$coefficients
A matrix: 4 × 4 of type dbl
EstimateStd. Errorz valuePr(>|z|)
(Intercept)-0.380.07-5.14e-07
ExpConditionO-0.050.09-0.66e-01
ExpConditionV 0.360.09 4.06e-05
IfSocial-0.040.07-0.56e-01
In [106]:
options(digits=3)
summary(BInomial_cat)$coefficients
A matrix: 4 × 4 of type dbl
EstimateStd. Errorz valuePr(>|z|)
(Intercept)-0.37690.0744-5.0674.05e-07
ExpConditionO-0.05240.0916-0.5725.67e-01
ExpConditionV 0.36310.0904 4.0165.91e-05
IfSocial-0.04070.0744-0.5475.85e-01
In [107]:
AIC(BInomial_cat)
401.078513128834

SVO as continuous¶

Items are scaled¶
In [108]:
BInomial_cont_scale<-glm(data = ExpDfSVOG1,cbind(Exploration, 50-Exploration)~ExpCondition+scale(PSocScore), family =binomial)
In [109]:
summary(BInomial_cont_scale)
Call:
glm(formula = cbind(Exploration, 50 - Exploration) ~ ExpCondition + 
    scale(PSocScore), family = binomial, data = ExpDfSVOG1)

Deviance Residuals: 
   Min      1Q  Median      3Q     Max  
-3.454  -0.967   0.002   1.090   3.366  

Coefficients:
                 Estimate Std. Error z value Pr(>|z|)    
(Intercept)       -0.3967     0.0645   -6.15  7.8e-10 ***
ExpConditionO     -0.0510     0.0915   -0.56     0.58    
ExpConditionV      0.3599     0.0904    3.98  6.9e-05 ***
scale(PSocScore)  -0.0522     0.0374   -1.39     0.16    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 161.35  on 59  degrees of freedom
Residual deviance: 133.80  on 56  degrees of freedom
AIC: 399.4

Number of Fisher Scoring iterations: 4
In [110]:
options(digits=1)
summary(BInomial_cont_scale)$coefficients
A matrix: 4 × 4 of type dbl
EstimateStd. Errorz valuePr(>|z|)
(Intercept)-0.400.06-6.18e-10
ExpConditionO-0.050.09-0.66e-01
ExpConditionV 0.360.09 4.07e-05
scale(PSocScore)-0.050.04-1.42e-01
In [111]:
options(digits=3)
summary(BInomial_cont_scale)$coefficients
A matrix: 4 × 4 of type dbl
EstimateStd. Errorz valuePr(>|z|)
(Intercept)-0.39670.0645-6.1497.81e-10
ExpConditionO-0.05100.0915-0.5585.77e-01
ExpConditionV 0.35990.0904 3.9796.92e-05
scale(PSocScore)-0.05220.0374-1.3931.64e-01
In [112]:
AIC(BInomial_cont_scale)
399.435856439912
Items are not scaled¶
In [113]:
BInomial_cont<-glm(data = ExpDfSVOG1,cbind(Exploration, 50-Exploration)~ExpCondition+PSocScore, family =binomial)
In [114]:
BInomial_cont
Call:  glm(formula = cbind(Exploration, 50 - Exploration) ~ ExpCondition + 
    PSocScore, family = binomial, data = ExpDfSVOG1)

Coefficients:
  (Intercept)  ExpConditionO  ExpConditionV      PSocScore  
      -0.3311        -0.0510         0.3599        -0.0137  

Degrees of Freedom: 59 Total (i.e. Null);  56 Residual
Null Deviance:	    161 
Residual Deviance: 134 	AIC: 399
In [115]:
options(digits=2)
summary(BInomial_cont)
Call:
glm(formula = cbind(Exploration, 50 - Exploration) ~ ExpCondition + 
    PSocScore, family = binomial, data = ExpDfSVOG1)

Deviance Residuals: 
   Min      1Q  Median      3Q     Max  
-3.454  -0.967   0.002   1.090   3.366  

Coefficients:
              Estimate Std. Error z value Pr(>|z|)    
(Intercept)   -0.33106    0.07997   -4.14  3.5e-05 ***
ExpConditionO -0.05105    0.09153   -0.56     0.58    
ExpConditionV  0.35987    0.09044    3.98  6.9e-05 ***
PSocScore     -0.01367    0.00981   -1.39     0.16    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 161.35  on 59  degrees of freedom
Residual deviance: 133.80  on 56  degrees of freedom
AIC: 399.4

Number of Fisher Scoring iterations: 4
In [116]:
options(digits=1)
summary(BInomial_cont)$coefficients
A matrix: 4 × 4 of type dbl
EstimateStd. Errorz valuePr(>|z|)
(Intercept)-0.330.08-4.13e-05
ExpConditionO-0.050.09-0.66e-01
ExpConditionV 0.360.09 4.07e-05
PSocScore-0.010.01-1.42e-01
In [117]:
options(digits=3)
summary(BInomial_cont)$coefficients
A matrix: 4 × 4 of type dbl
EstimateStd. Errorz valuePr(>|z|)
(Intercept)-0.33110.07997-4.1403.48e-05
ExpConditionO-0.05100.09153-0.5585.77e-01
ExpConditionV 0.35990.09044 3.9796.92e-05
PSocScore-0.01370.00981-1.3931.64e-01
In [118]:
AIC(Gaus_cont_scale,Gaus_cat_scale,BInomial_cont_scale,BInomial_cat)
A data.frame: 4 × 2
dfAIC
<dbl><dbl>
Gaus_cont_scale5168
Gaus_cat_scale5168
BInomial_cont_scale4399
BInomial_cat4401